exceltime
Converts datetime values to Excel serial date numbers.
Category: Language Fundamentals > Data Types
Syntax
E = exceltime(T)
Returns Excel serial dates for the datetime array T.
Description
Excel stores a date as the number of days since an epoch, with the time of day as a fraction of a day. In the 1900 system, 1 January 2024 is 45292. Noon is 0.5, so noon on that day is 45292.5.
Input arguments
Tdatetimearray.
Output arguments
E- Double array, same size as
T. Days are the integer part; the time of day is the fraction.
Example
Dates to serial numbers
format long
exceltime(datetime(2024, 1, 1))
exceltime(datetime(2024, 1, 1, 12, 0, 0))
Output
ans = 45292
ans = 4.529250000000000e+04