例: CDat 関数

CDat 関数のプログラミング例を 2 つ示します。

例 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

 

例 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