Skip to main content

DateConvert

Converts dates between internal and external formats.

Synopsis

DateConvert(date,vbToInternal)
DateConvert(date,vbToExternal)

Arguments

date The date to be converted. An external date is represented as a string, such as “10–22–1980”. An internal date is represented as a five-digit integer, which is the first part of the Caché $HOROLOG ($H) date/time format.
vbToInternal This keyword specifies converting an external date to internal ($H) format.
vbToExternal This keyword specifies converting an internal date ($H format) to external date format.

Description

If you specify a date/time value, DateConvert ignores the time portion.

The DateConvert function returns an external date in the following format:

mm/dd/yyyy

Leading zeros are displayed. The year is displayed as four digits.

The DateConvert function returns an internal date/time in the following format:

ddddd

Where “d” is the date count (number of days since 12/31/1840). 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).

Examples

The following example takes an external date/time value, converts the date part to an internal format ($HOROLOG) value, then converts this internal value back to an external format date.

Dim GetDate,InDate, ExDate
GetDate = "1-12-1953 11:45:23"
Println GetDate
InDate = DateConvert(GetDate,vbToInternal)
Println InDate
ExDate = DateConvert(InDate,vbToExternal)
Println ExDate

The values printed are as follows:

1-12-1953 11:45:23
40919
01/12/1953

See Also

FeedbackOpens in a new tab