MATLAB Function Reference
  Go to function:
    Search    Help Desk 
datestr    See Also

Date string format

Syntax

str = datestr(D,dateform,P)

Description

str = datestr(D,dateform) converts each element of the array of serial date numbers (D) to a 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(D,dateform,P) assumes that two-character years lie within the 100-yearperiod beginning with the pivot year p. 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:

dateform (number)
dateform (string)
Example
0
'dd-mmm-yyyy HH:MM:SS'
01-Mar-1995 03:45
1
'dd-mmm-yyyy'
01-Mar-1995
2
'mm/dd/yy'
03/01/95
3
'mmm'
Mar
4
'm'
M
5
'mm'
3
6
'mm/dd'
03/01
7
'dd'
1
8
'ddd'
Wed
9
'd'
W
10
'yyyy'
1995
11
'yy'
95
12
'mmmyy'
Mar95
13
'HH:MM:SS'
15:45:17
14
'HH:MM:SS PM'
03:45:17 PM
15
'HH:MM'
15:45
16
'HH:MM PM'
03:45 PM
17
'QQ-YY'
Q1-96
18
'QQ'
Q1

NOTE
dateform numbers 0, 1, 2, 6, 13, 14, 15, and 16 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', ... may also be part of the input array D. If you do not specify dateform, the date string format defaults to

See Also

date, datenum, datevec



[ Previous | Help Desk | Next ]