datenum

Returns the day and time input as a number of days since January 1, 0000.

Syntax

R = datenum(year, month, day)

R = datenum(year, month, day, hour)

R = datenum(year, month, day, hour, minute)

R = datenum(year, month, day, hour, minute, second)

Inputs

year, month, day, hour, minute, second
Type: double | integer
Dimension: scalar

Outputs

R
Resulting scalar.

Example

Simple datenum example:

printf('Days passed since January 1, 0000:\n')
printf('On February 1, 2016: %d\n', datenum(2016, 2, 1))
printf('On March 1, 2016: %d\n', datenum(2016, 3, 1))
printf('A difference of %d days', datenum(2016, 3, 1) - datenum(2016, 2, 1))

Days passed since January 1, 0000:
On February 1, 2016 are 736361
On March 1, 2016 are 736390
A difference of 29 days