Share via

The Date Data Type

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Microsoft® Visual Basic® for Applications (VBA) provides the Date data type to store date and time values. The Date data type is an 8-byte floating-point value, so internally it is the same as the Double data type. The Date data type can store dates between January 1, 100, and January 1, 9999.

VBA stores the date value in the integer portion of the Date data type, and the time value in the decimal portion. The integer portion represents the number of days since December 30, 1899, which is the starting point for the Date data type. Any dates before this one are stored as negative numbers; all dates after are stored as positive values. If you convert a date value representing December 30, 1899, to a double, you'll find that this date is represented by zero.

The decimal portion of a date represents the amount of time that has passed since midnight. For example, if the decimal portion of a date value is .75, three-quarters of the day has passed, and the time is now 6 P.M.

Because the integer portion of a date represents number of days, you can add and subtract days from one date to get another date.

See Also

Working with Dates and Times | Getting the Current Date and Time | Formatting a Date | Date Delimiters | Assembling a Date | Getting Part of a Date | Adding and Subtracting Dates | Calculating Elapsed Time