Caché Basic Reference
DateTimeConvert
[Back] [Next]
   
Server:docs2
Instance:LATEST
User:UnknownUser
 
-
Go to:
Search:    

Converts date/time between internal and external formats.
Synopsis
DateTimeConvert(datetime,vbToInternal)
DateTimeConvert(datetime,vbToExternal)
Arguments
datetime The date and time to be converted. An external date/time is represented as a string, such as “10–22–1980 12:35:56”. An internal date/time is represented by the Caché $HOROLOG ($H) date/time format: two five-digit integer values separated by a comma.
vbToInternal This keyword specifies converting an external date/time to internal ($H) format.
vbToExternal This keyword specifies converting an internal date/time ($H format) to external date and time format.
Description
The DateTimeConvert function returns an external date/time in the following format:
mm/dd/yyyy hh:mm:ss
Leading zeros are displayed. The year is displayed as four digits.
The DateTimeConvert function returns an internal date/time in the following format:
ddddd,sssss.ff
Where “ddddd” is the date count (number of days since 12/31/1840), “sssss” is the time count (number of elapsed seconds in the specified day), and “ff” is optional fractional seconds. Fractional seconds are preserved in converting from external to internal format; fractional seconds are truncated when converting from internal to external format. For further details, see $HOROLOG in the Caché ObjectScript Reference.
An omitted year value defaults to 2000; the two-digit year defaults are 2000 through 2029 (for 00 through 29) and 1930 through 1999 (for 30 through 99).
An omitted time value defaults to 00:00:00.
Examples
In the following example the DateTimeConvert function returns a date/time in internal format.
Dim InDateTime
InDateTime = DateTimeConvert("Nov 11 1953 12:35:00",vbToInternal)
Println InDateTime
 
The following example takes an external date/time value with fractional seconds, converts it to an internal format ($HOROLOG) value, then converts this internal value back to an external format date and time.
Dim GetDate,InDate, ExDate
GetDate = "1-12-1953 11:45:23.99"
Println GetDate
InDate = DateTimeConvert(GetDate,vbToInternal)
Println InDate
ExDate = DateTimeConvert(InDate,vbToExternal)
Println ExDate
 
The values printed are as follows:
1-12-1953 11:45:23.99
40919,42323.99
01/12/1953 11:45:23
See Also