Examples: CDat function
Here are two programming examples of the CDat function.
Example 1
Dim dateV As Variant
' Convert a numeric value to a date/time value.
dateV = CDat(34814.3289)
' Display the formatted date and time.
Print Format$(dateV, "Medium Date"), _
Format$(dateV, "Medium Time")
' Prints 25-Apr-95 07:53 AM
' Convert the date back to a number.
Print CDbl(dateV) ' Prints 34814.3289
' Convert a date string to a date.
Print CDat("April 25, 1995") ' Prints 4/25/95
Example 2
print CDat(-1) ,cdate(0), cdate(1)
'Output is 12/29/1899 12:00:00 AM 12/31/1899
print CDat("23:59:59"), cdat("00:00:00"), cdat("00:00:01")
'Output is 11:59:59 PM 12:00:00 AM 12:00:01 AM