MATLAB Function Reference | ![]() ![]() |
Syntax
Description
The datestr
function converts serial date numbers (defined by datenum
) and date vectors (defined by datevec
) into date strings.
str = datestr(DT,dateform)
converts a single date vector, or each element of an array of serial date numbers to a date string. Date strings with two-character years, e.g., 12-june-12
, are assumed to lie within the 100-year period centered about the current year.
str = datestr(DT,dateform,P)
uses the specified pivot year as the starting year of the 100-year range in which a two-character year resides. The default pivot year is the current year minus 50 years.
The optional argument dateform
specifies the date format of the result. dateform
can be either a number or a string:
NOTE
dateform numbers 0 , 1 , 2 , 6 , 13 , 14 , 15 , 16 , and 23 produce a string suitable for input to datenum or datevec . Other date string formats will not work with these functions. |
Time formats like 'h:m:s'
, 'h:m:s.s'
, 'h:m pm'
, ... can also be part of the input array DT
. If you do not specify dateform
, or if you specify dateform
as -1
, the date string format defaults to
See Also
date
, datetick
, datenum
, datevec
![]() | datenum | datetick | ![]() |