Financial Toolbox | ![]() ![]() |
Syntax
DateString = datestr(Date, DateForm) DateString = datestr(Date, DateForm, Pivot) DateString = datestr(Date)
Description
DateString = datestr(Date, DateForm)
converts a date number or a date string to a date string. DateForm
specifies the format of DateString
. 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.
DateString = datestr(Date, DateForm, Pivot)
assumes that two-character years lie within the 100-year period beginning with the pivot year. The default pivot year is the current year minus 50 years.
DateString = datestr(Date)
assumes DateForm
is 1
, 16
, or 0
depending on whether the date number Date
contains a date, time, or both, respectively. If Date
is a date string, the function assumes DateForm
is 1
.Note: This function now ships with basic MATLAB. It originally shipped only with the Financial Toolbox. This description remains here for your convenience. |
Examples
DateString = datestr(730123, 1) DateString = 03-Jan-1999 DateString = datestr(730123, 2) DateString = 01/03/99 DateString = datestr(730123, 12) DateString = Jan99 DateString = datestr(730123.776, 0) DateString = 03-Jan-1999 18:37:26 DateString = datestr('1/03', 1) (assuming the current year is 1999) DateString = 03-Jan-1999 DateString = datestr(730123) DateString = 03-Jan-1999 DateString = datestr([730123 730154 730182 730213 730243 730274]) DateString = 03-Jan-1999 03-Feb-1999 03-Mar-1999 03-Apr-1999 03-May-1999 03-Jun-1999 DateString = datestr('1/03') DateString = 03-Jan-1999 (assuming the current year is 1999)
See Also
dateaxis
, datedisp
, datenum
, datevec
, daysact
, now
, today
![]() | datenum | datevec | ![]() |