CDat function (LotusScript® Language)

Converts a numeric value or string value to a date/time value.

Syntax

CDat ( expr )

CVDate is acceptable in place of CDat.

Elements

expr

Any of the following kinds of expression:

  • A numeric expression
  • A string expression that can be converted to a number
  • A string expression that can be converted to a date/time value

Return value

CDat returns a date/time value.

The data type of the return value is a Variant of DataType 7 (Date/Time).

If the integer part of expr is not in the range -657434 to 2958465, the function raises an error.

CDat(0) returns the date/time value December 30, 1899, 12:00:00 AM, formatted as 12:00:00 AM. CDat(EMPTY) returns the same value.

Usage

CDat converts expr to a date/time value in the LotusScript® date/time format.

CDat uses different conversion rules depending on the form of expr:

  • If expr is a numeric expression, CDat converts the integer part of its value to a date and the fractional part to a time, and returns the corresponding date/time value.

    A date/time value stored in a Variant is an eight-byte floating-point value. The integer part represents a serial day counted from Jan 1, 100 AD. Valid dates are represented by integer numbers in the range -657434, representing Jan 1, 100 AD, to 2958465, representing Dec 31, 9999 AD. The fractional part represents the time as a fraction of a day, measured from time 00:00:00 (midnight on the previous day). In this representation of date/time values, day 1 is the date December 31, 1899.

  • If expr is a string expression that can be converted to a number, CDat converts the string to a number and then converts the number to a date/time value and returns the result, as described in the previous bullet.
  • If expr is a string expression in the form of a date, for example "8/20/98", CDat converts the value to a date/time in the internal date/time format.

If LotusScript® cannot convert the value to a date/time, the function raises an error.

Example