Navigation

Operators and Keywords

Function List:

C++ API

: days = datenum (datevec)
: days = datenum (year, month, day)
: days = datenum (year, month, day, hour)
: days = datenum (year, month, day, hour, minute)
: days = datenum (year, month, day, hour, minute, second)
: days = datenum ("datestr")
: days = datenum ("datestr", f)
: days = datenum ("datestr", p)
: [days, secs] = datenum (…)

Return the date/time input as a serial day number, with Jan 1, 0000 defined as day 1.

The integer part, floor (days) counts the number of complete days in the date input.

The fractional part, rem (days, 1) corresponds to the time on the given day.

The input may be a date vector (see datevec), datestr (see datestr), or directly specified as input.

When processing input datestrings, f is the format string used to interpret date strings (see datestr). If no format f is specified, then a relatively slow search is performed through various formats. It is always preferable to specify the format string f if it is known. Formats which do not specify a particular time component will have the value set to zero. Formats which do not specify a date will default to January 1st of the current year.

p is the year at the start of the century to which two-digit years will be referenced. If not specified, it defaults to the current year minus 50.

The optional output secs holds the time on the specified day with greater precision than days.

Notes:

  • Years can be negative and/or fractional.
  • Months below 1 are considered to be January.
  • Days of the month start at 1.
  • Days beyond the end of the month go into subsequent months.
  • Days before the beginning of the month go to the previous month.
  • Days can be fractional.

Caution: this function does not attempt to handle Julian calendars so dates before October 15, 1582 are wrong by as much as eleven days. Also, be aware that only Roman Catholic countries adopted the calendar in 1582. It took until 1924 for it to be adopted everywhere. See the Wikipedia entry on the Gregorian calendar for more details.

Warning: leap seconds are ignored. A table of leap seconds is available on the Wikipedia entry for leap seconds.

See also: datestr, datevec, now, clock, date.

Package: octave