Financial Toolbox    
datestr

Create date string

Syntax

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.

DateForm
Format
Example
0
'dd-mmm-yyyy HH:MM:SS'
01-Mar-2000 15:45:17
1
'dd-mmm-yyyy'
01-Mar-2000
2
'mm/dd/yy'
03/01/00
3
'mmm'
Mar
4
'm'
M
5
'mm'
03
6
'mm/dd'
03/01
7
'dd'
01
8
'ddd'
Wed
9
'd'
W
10
'yyyy'
2000
11
'yy'
00
12
'mmmyy'
Mar00
13
'HH:MM:SS'
15:45:17
14
'HH:MM:SS PM'
3:45:17 PM
15
'HH:MM'
15:45
16
'HH:MM PM'
3:45 PM
17
'QQ-YY'
Q1-01
18
'QQ'
Q1
19
'dd/mm'
01/03
20
'dd/mm/yy'
01/03/00
21
'mmm.dd.yyyy HH:MM:SS'
Mar.01,2000 15:45:17
22
'mmm.dd.yyyy'
Mar.01.2000
23
'mm/dd/yyyy'
03/01/2000
24
'dd/mm/yyyy'
01/03/2000
25
'yy/mm/dd'
00/03/01
26
'yyyy/mm/dd'
2000/03/01
27
'QQ-YYYY'
Q1-2001
28
'mmmyyyy'
Mar2000

Examples

See Also

dateaxis, datedisp, datenum, datevec, daysact, now, today


  datenum datevec