Programming Previous page   Next Page

Date String Formats

The datenum function is important for doing date calculations efficiently. datenum takes an input string in any of several formats, with 'dd-mmm-yyyy', 'mm/dd/yyyy', or 'dd-mmm-yyyy,' most common. You can form up to six fields from letters and digits separated by any other characters:

For example, if the current year is 1996, then these are all equivalent:

and both of these represent the same time:

Note that the default format for numbers-only input follows the American convention. Thus 3/6 is March 6, not June 3.

If you create a vector of input date strings, use a column vector and be sure all strings are the same length. Fill in with spaces or zeros.

Previous page  Conversions Between Date Formats Output Formats Next page

© 1994-2005 The MathWorks, Inc.