datenum

Return the date/time input as a serial day number.

Syntax

  • d = datetnum(datevec)

  • d = datenum(datestr)

  • d = datenum(datestr, format)

  • d = datenum(datestr, pivotYear)

  • d = datenum(DateString,format,pivotYear)

  • d = datetnum(Y, M, D)

  • d = datetnum(Y, M, D, H, MN, S)

Input argument

  • datevec - a vector: [Y, M, D, H, MN, S] or matrix N x 6.

  • format - a string: date format.

  • datestr - a string, cell of string or string array: text representing a date.

  • Y, M, D, H, MN, S - double: Year, Month, Day, Hours, Minutes, Secondes (scalar or vector).

  • pivotYear: Start year of 100-year date range - integer value or present minus 50 years (default).

Output argument

  • d - a double: serial date number (serial day 1 corresponds to 1-Jan-0000).

Description

d = datenum() returns the serial date number corresponding to current date.

d = datenum(datevec) converts date vector to serial date number.

d = datenum(datestr) and d = datenum(datestr, format) converts string to serial date number.

Supported format conversion:

dd-mmm-yyyy HH:MM:SS 10-Mar-2010 16:48:17

dd-mmm-yyyy 10-Mar-2010

mm/dd/yyyy 03/10/2010

mm/dd/yy 03/10/00

mm/dd 03/10

mmm.dd,yyyy HH:MM:SS Mar.10,2010 16:48:17

mmm.dd,yyyy Mar.10,2010

yyyy-mm-dd HH:MM:SS 2010-03-10 16:48:17

yyyy-mm-dd 2010-03-10

yyyy/mm/dd 2000/03/10

HH:MM:SS 16:48:17

HH:MM:SS PM 3:48:17 PM

HH:MM 16:48

HH:MM PM 3:35 PM

If format is not specified, the default format is dd-mmm-yyyy.

If format is specified and not using predefined format, the format must be specified as a character vector or string scalar composed of symbolic identifiers.

The format of the input text for representing dates and times, expressed as a character vector or string scalar composed of symbolic identifiers.

Example

d = datenum([1973,8,4,12,1,18])
datevec(d)
d = datenum('04–Aug-1973 12:01:18')
d = datenum(["04–Aug-1973 12:01:18"; "04–Aug-1974 11:01:18"])

See also

datevec.

History

Author

Allan CORNET

Last updated