Date Data Type Structure
- Last UpdatedJul 18, 2023
- 1 minute read
The date data type structure in VBA is a junction of two very different methods of data storage. It is formed from the serial concatenation of a date-value followed by a time-value, separated by a floating point, and stored in an 8-byte floating-point date data type value.
-
The integer (whole) portion of the value represents the number of days elapsed since December 30, 1899.
-
The remainder (fractional) portion of the value represents the elapsed portion of the day since midnight.
The integer (date-value) portion (to the left of the floating point) and the remainder (time-value) portion (to the right of the floating point) must be handled differently as they are structured very differently. VBA has a number of pre-defined date and time functions to convert between the internal floating-point date data type format and visibly recognizable dates and times.
Note: Dates in VBA are based upon the Gregorian Calendar.
For example, the date and time of 5/22/97 at 3:00 p.m. would be stored in VBA as 35572.625 representing the 35572 days since 12/30/1899, and 3:00 p.m. as 625/1000 of a full day.
Note: Don't confuse Date data types used in VBA with date and time values used in Windows, DLLs, Plant SCADA, or in Cicode. For instance, Plant SCADA stores time/date-related variables as a single integer representing the number of seconds since 01/01/1970.