Stores date and time.
Note: In most cases use DateTime type instead. Its purpose is the same as of DATE. It has more functions and supports milliseconds. Use DATE only with functions that need it, for example COM functions.
The DATE type is implemented using a floating-point number (double). Days are represented by whole number increments starting with 30 December 1899, midnight as time zero. Time values are expressed as fractional part. Time precision is 1 second. Also can be used to represent date-only (the fractional part is 0) or time-only (the whole number part is 0).
To remove the time part (leave only the date part) from a DATE variable, you can assign it to an int variable. However, when converting DATE to int, result may be rounded up. To prevent it, use the member variable date. See examples.
DATE supports operator = (assign). Use it to convert string (str, lpstr, BSTR, VARIANT) containing date to DATE and vice versa.
To format date/time string, use str.timeformat.
To store date and time, also often are used types SYSTEMTIME and FILETIME:
type SYSTEMTIME @wYear @wMonth @wDayOfWeek @wDay @wHour @wMinute @wSecond @wMilliseconds type FILETIME dwLowDateTime dwHighDateTime
Here var is a variable of type DATE. Where the return type is not specified, the function returns var itself.
Gets current time.
Converts from SYSTEMTIME to DATE type and vice versa. Here st is a variable of type SYSTEMTIME.
Converts from FILETIME to DATE type and vice versa. Here ft is a variable of type FILETIME.
Use DateTime class instead. If need DATE type, you can convert it to/from DateTime with its functions FromDATE and ToDATE. Also you can use other functions from the time category, for example TimeSpanGetPartsTotal.
Adds diff to var. Here diff is a date span variable. With DATE functions, date span (difference between two dates) is a variable of type SYSTEMTIME.
Use this function when date span is quite complex. To add/subtract days, you can use operator + or -. For example, var=var-2 subtracts 2 days; var=var+(4/24.0) adds 4 hours.
Subtracts diff from var.
double var.diff(date2 [diff] [part])
Returns difference between var and date2. The return value is negative if var is less than date2, 0 if var is equal to date2, positive if var is greater than date2.
diff can be 0 or a variable of type SYSTEMTIME. It receives date span (always positive).
By default, returns difference in days. If part is 1 then returns difference in hours, 2 - minutes, 3 - seconds.
Always returns whole number. To get exact difference between two dates, use operator -. Example: diff=var-date2.
DATE d="4/1/2003" add 2 days d=d+2 out d remove the time part DATE d=10.55 int i=d out i ;;11 (rounded up) i=d.date out i ;;10 (ok)