Scripting > UNICOM Intelligence Function Library > Conversion functions > CDate
 
CDate
Converts a value of any data type to a Date value.
Syntax
CDate(Val)
Parameters
Val
Type: None
Variant value to be converted.
(return)
Type: Date
Date value derived from Val.
Remarks
The converted dates are held in Microsoft variant date standard format. Converting other data types to a date is likely to give meaningless results.
The result of the conversion depends on the data type of Val, as follows:
Boolean
The return value is likely to be meaningless.
Long
The day is Val days after 30 December 1899 (or before, if Val is negative) and the time is 00:00:00.
Double
The return value is the date and time resulting from using Val as the internal representation of the date.
Date
Val is returned unchanged.
Text
The string is parsed according to the locale to extract the value. An error occurs if the string does not contain a properly formatted date.
Categorical
An error occurs.
Object
If the object has a default property, the value of that property is converted. Otherwise an error occurs.
NULL values
If Val is NULL, the return value is 30 December 1899 00:00:00.
This function is similar to CDate in Visual Basic.
Examples
Data Type
Value
Result
Long
37430
6/23/2002
Double
37429.56
6/22/2002 1:26:24 PM
Text
14 April 2001 20:30:02
4/14/2001 8:30:02 PM
Text
Fossils
Error
Categorical
{5,3,1,9}
Error
See also
CBoolean
Conversion functions