Programming Previous page   Next Page

Output Formats

The command datestr(D, dateform) converts a serial date D to one of 19 different date string output formats showing date, time, or both. The default output for dates is a day-month-year string: 01-Mar-1996. You select an alternative output format by using the optional integer argument dateform.

This table shows the date string formats that correspond to each dateform value.

dateform
Format
Description
0
01-Mar-1996 15:45:17
day-month-year hour:minute:second
1
01-Mar-1996
day-month-year
2
03/01/96
month/day/year
3
Mar
month, three letters
4
M
month, single letter
5
3
month
6
03/01
month/day
7
1
day of month
8
Wed
day of week, three letters
9
W
day of week, single letter
10
1996
year, four digits
11
96
year, two digits
12
Mar96
month year
13
15:45:17
hour:minute:second
14
03:45:17 PM
hour:minute:second AM or PM
15
15:45
hour:minute
16
03:45 PM
hour:minute AM or PM
17
Q1-96
calendar quarter-year
18
Q1
calendar quarter

Converting Output Format with datestr

Here are some examples of converting the date March 1, 1996 to various forms using the datestr function:


Previous page  Date String Formats Current Date and Time Next page

© 1994-2005 The MathWorks, Inc.