DateTime Functions

Use

Function

Description

Syntax

Examples

DATETIME

Returns the exact time stamp in a calendar date specified by the given year , month , day , hour , minute , second , and timezone parts. The second and timezone parts are optional and default to 0 and front-end server time zone, respectively.

DATETIME(year,month, day,hour, minute,[second],[timezone])

where timezone can be either a signed offset (±00:00-23:00) or the letter Z used to represent the UTC time zone (Coordinated Universal Time)

DATETIME(2005,4,23,13,30)

Compiles the exact time stamp in a calendar date according to the given values. In this case, the above example would return 23/4/2005 13:30

DTADD

Increases/decreases a datetime value by the specified number of date or time ( c ) units. The unit part is optional and defaults to 'D' (days).

DTADD (c,n,[unit])

where unit is one of the items listed in the Date Units or Time Units tables

DTADD(@23/4/2009 13:30,4,'D')

Adds 4 days to the value returned. In this case, the above example would be converted to 27/4/2009 13:30

DTGET

Returns the numeric value of the specified date or time ( c ) unit.

DTGET(c,unit)

where unit is one of the items listed in the Date Units or Time Units tables

DTGET(@CREATE_DATETIME,'D')

Returns only the value of the specified date or time unit from within the datetime value. In this case, 23/4/2009 13:30,'D' would return 23 , while 23/4/2009 13:30,'H' would return 13

DTSTR

Converts a datetime object to a formatted string. The format part is optional, and defaults to 'DATETIME'.

DTSTR (c,[format])

where format is devised from the set of special characters listed in the DateTime Formats table

DTSTR(@DATETIME_FIELD,'HH:MI, MON D, YYYY')

Converts the datetime value returned to a string. In this case, 23/4/2009 13:30 would be converted to 13:30, Apr 23, 2009

DTSUB

Returns the difference between two datetime objects, in the specified date or time unit. The unit part is optional and defaults to 'D' (days).

DTSUB (c1,c2,[ unit] )

where unit is one of the items listed in the Date Units or Time Units tables

DTSUB(24/4/2005 14:30, 23/4/2005 13:30,'H')

Calculates the difference in the two datetime objects, specified here, in hours. In this case, the above example would return 25

DTVAL

Converts a string containing a datetime value to a datetime object.

DTVAL(str)

DTVAL(23/4/2009 13:30)

Converts a string containing a datetime value to a datetime object. In this case, the above example would be converted to the datetime object that represents the time stamp 23/04/2009 13:30:00 , in the front-end server's timezone.

DTNOW

Returns the current time stamp in a calendar date.

DTNOW()

DTNOW()

Returns the current time stamp in a calendar date, such as:

27/06/2009 17:04:20