Date and time functions

From Genesys Documentation
Jump to: navigation, search
This topic is part of the manual Field Codes Reference Guide for version Current of Routing and Designer.

Learn about the date and time functions you can use in field codes.

Related documentation:

Field codes can use the date/time functions detailed on this page.

Date

Date(Year, Month, Day [, Hour[, Minute[, Second ]]]) Or Date(String[, String])

Returns a Date/Time constructed from individual components or a string.

Important
Date(String[, String]) is not recommended.

When using the first syntax function, the optional arguments each default to 0 if omitted. For example, <$Date(1965, 11, 23)$> is equivalent to <$Date(1965, 11, 23, 0, 0, 0)$>.

When using the second syntax function, the date is constructed by parsing the first string. If the optional argument is omitted, the value of an internal configuration option is used, if present - contact your Genesys representative for details. Otherwise, the platform locale is used. For example:

  • <$Date("November 23, 1965 9:03 AM")$> if the fieldcode-format-locale option or platform locale is set to en_US.
  • <$Date(“23 novembre 1965 21:03:00”, “fr_FR”)$>
Important
Avoid using this second syntax function, since it successively tries multiple Date/Time patterns in order to parse the first argument and so consumes a great deal of CPU time. Also, these patterns are not very lenient. For example, <$Date(“November 23, 1965, at 9:03 AM”)$> will not parse due to the word at. This method of constructing Date/Time values is less exact than specifying the individual components directly, and may yield incorrect results if the day appears before the month.
Date String
Argument Description
First argument The string to parse.
Second argument Optional. The locale that must be used to parse the first segment. Some examples include: en_US for English (United States), en_GB for English (United Kingdom), and fr_FR for French (France). The value must be in the following format: <two letter code of ISO 639>_<two letter code of ISO 3166>

Day

Day(DateTime)

Returns the numeric day component of a Date/Time (1 to 31).

Hour12

Hour12(DateTime)

Returns the numeric hour component of a Date/Time based on a 12-hour clock (1 to 12).

Hour24

Hour24(DateTime)

Returns the numeric hour component of a Date/Time based on a 24-hour clock (0 to 23).

IsAm

IsAm(DateTime)

Returns a Boolean indicating whether a specified Date/Time is AM (between midnight and noon). True indicates AM and False indicates PM.

IsPm

IsPm(DateTime)

Returns a Boolean indicating whether a specified Date/Time is PM (between noon and midnight). True indicates PM and False indicates AM.

Minute

Minute(DateTime)

Returns the numeric minute component of a Date/Time (0–59).

Month

Month(DateTime)

Returns the numeric month component of a Date/Time (1–12).

MonthName

MonthName(Arg[, String])

Converts a month number or a Date/Time to a month name. If the optional argument is omitted, the value of an internal configuration option is used, if present - contact your Genesys representative for details. Otherwise, the platform locale is used.

MonthName String
Argument Description
First argument If it is a numeric value (1 to 12 ), it is converted to the appropriate month name. If it is a Date/Time, the month number is extracted and converted.
Second argument Optional. The locale that must be used to format the first argument. Some examples include: en_US for English (United States), en_GB for English (United Kingdom), and fr_FR for French (France). The value must be in the following format: <two letter code of ISO 639>_<two letter code of ISO 3166>

MonthNameShort

MonthNameShort(Arg[, String])

The same as the MonthName, but this returns an abbreviated version of the month name instead. If the optional argument is omitted, the value of an internal configuration option is used, if present - contact your Genesys representative for details. Otherwise, the platform locale is used.

MonthNameShort String
Argument Description
First argument If it is a numeric value (1 to 12 ), it is converted to the appropriate month name. If it is a Date/Time, the month number is extracted and converted.
Second argument Optional. The locale that must be used to format the first argument. Some examples include: en_US for English (United States), en_GB for English (United Kingdom), and fr_FR for French (France). The value must be in the following format: <two letter code of ISO 639>_<two letter code of ISO 3166>

Second

Second (DateTime)

Returns the numeric second component of a Date/Time (0–59).

Time

Time ([Hour, [Minute, [Second]]])

Returns a Date/Time constructed from individual time components. The date components of the result (year, month, and day) are set to the current system date. The optional arguments default to 0 if omitted. If all the optional arguments are omitted, then the time is set to the current system time.

Important
The examples in the Examples of Time String table assume that the current system date is November 23, 2003, @ 09:03:10.
Examples of Time String
Example Result
<$Time()$> 2003-11-23 09:03:10
<$Time(15)$> 2003-11-23 15:00:00
<$Time(15, 23, 10)$> 2003-11-23 15:23:10

TimeGMT

TimeGMT()

Returns a Date/Time set to the current system time and converted to GMT (Greenwich mean time), also called Universal Time Coordinated, or UTC.

ToTimeZoneDate

ToTimeZoneDate(DateString, TimeZoneString)

Returns a Date/Time constructed from a string and a time zone. This date is constructed by parsing the <DateString> string and using the specified time zone <TimeZoneString>. Examples include the following:

  • <$ToTimeZoneDate(Date(“November 23, 1965 9:03 AM”), “America/Los_Angeles”)$>
  • <$ToTimeZoneDate(Date(“11/23/65 9:03:00”), “Europe/Paris”)$>

Weekday

Weekday (DateTime)

Returns the numeric weekday component of a Date/Time (0 = Sunday to 6 = Saturday).

WeekdayName

WeekdayName(Arg[, String])

Converts a number of a Date/Time to a weekday name. If the optional argument is omitted, the value of an internal configuration option is used, if present - contact your Genesys representative for details. Otherwise, the platform locale is used.

WeekdayName String
Argument Description
First argument If it is a numeric value (0 to 6 ), it is converted to the appropriate weekday name. If it is a Date/Time, the weekday number is extracted and converted.
Second argument The locale that must be used to format the first argument. Some examples include: en_US for English (United States), en_GB for English (United Kingdom), andfr_FR for French (France). The value must be in the following format: <two letter code of ISO 639>_<two letter code of ISO 3166>

WeekdayNameShort

WeekdayNameShort(Arg[, String])

The same as WeekdayName but this returns an abbreviated weekday name instead. If the optional argument is omitted, the value of an internal configuration option is used, if present - contact your Genesys representative for details. Otherwise, the platform locale is used.

WeekdayNameShort String
Argument Description
First argument If it is a numeric value (0 to 6 ), it is converted to the appropriate weekday name. If it is a Date/Time, the weekday number is extracted and converted.
Second argument The locale that must be used to format the first argument. Some examples include: en_US for English (United States), en_GB for English (United Kingdom), and fr_FR for French (France). The value must be in the following format: <two letter code of ISO 639>_<two letter code of ISO 3166>

Year

Year (DateTime)

Returns the numeric year component of a Date/Time with the century.

YearShort

YearShort (DateTime)

Returns the numeric year component of a Date/Time without the century (099).

Retrieved from "https://all.docs.genesys.com/PEC-ROU/Current/FldCod/DatTim (2024-04-18 02:31:35)"
Comments or questions about this documentation? Contact us for support!