Documentation

Date and Time

These functions perform operations and comparisons on dates and times.

datecmp

Description

The datecmp() function compares two dates and returns the results of the comparison.

The two input parameters, date1 and date2, contain the date strings to compare. These fields should have the format YYYY/MM/DD, where:

YYYY: A year numeric character string such as 2001. If the specified year is only two digits, then that value is automatically concatenated with 19 to form a year between 1900 and 1999, inclusive. For example, if the value 01 is supplied for year, the actual year value is processed as 1901.

MM: Month between 1 and 12 inclusive

DD: Day between 1 and 31 inclusive.

Use the forward slash character (/) as a field separator. Zeros or spaces can be used as leading pad characters for the year, month, or day.

Syntax

result = datecmp (date1, date2);

Arguments

date1Required. Character string containing a date formatted as YYYY/MM/DD
date2Required. Character string containing a date formatted as YYYY/MM/DD

Return values

Negative Integer:- A negative integer is returned if date1 is less than date2 (date1 < date2).
0Zero is returned if date1 is equal to date2 (date1 == date2).
Positive IntegerA positive integer is returned if date1 is greater than date2 (date1 < date2).

Example

In this example, datecmp compares the value in date1 against the date January 21, 2002. The result is returned in result. Because date1 contains the date 2001/01/21, the result of datecmp is a negative integer because date1 is less than date2.

date1 = "2001/01/21";
result = datecmp (date1, "2002/01/21");

strftime

Description

The strftime() function formats the current date and time, as defined on Policy Server host, per the supplied format string.

ℹ️

Note

For more information on how to create a format string, see Time Format Commands.

Note that different operating systems may provide different options for their own native strftime() function. Consult your operating system’s strftime() manual page for more information.

Syntax

result = strftime (formatstring);

Arguments

formatstringRequired. Character string that contains the format command characters that specify how the current date should be formatted.

Return values

strftime() returns a formatted character string containing the current date and time from the Policy Server host.

See also

date, day, dayname, hour, minute, month, time, year

timebetween

Description

The timebetween() function determines whether the current time, as defined on the Policy Server host, is between time1 and time2, inclusive.

The time1 and time2 parameters contain integer time values. These time values should be specified in military time (HHMM) format, where:

HH: A number from 0 to 23, inclusive, that represents the hour

MM: A number between 0 to 59, inclusive, that represents the minutes

If time2 < time1, the comparison crosses the midnight boundary.

Syntax

result = timebetween (time1, time2);

Arguments

time1Required. An integer containing a time value formatted as HHMM
time2Required. An integer containing a time value formatted as *HHMM

Return values

trueThe current time is between time1 and time2 or the current time is equal to either time1 or time2.
falseThe current time is either less time1 or greater than time2.

Example

In the example,

result = timebetween (1100, 1500);

the following times set result as follows:

  • 08:00 result set to false
  • 11:00 result set to true
  • 12:30 result set to true
  • 15:00 result set to true
  • 15:01 result set to false

©2003-2025 BeyondTrust Corporation. All Rights Reserved. Other trademarks identified on this page are owned by their respective owners. BeyondTrust is not a chartered bank or trust company, or depository institution. It is not authorized to accept deposits or trust accounts and is not licensed or regulated by any state or federal banking authority.