MATLAB Functions Help Desk

datestr

Purpose

Date string format

Syntax

Description

str = datestr(D,dateform) converts each element of the array of serial date numbers (D) to a string. Optional argument dateform specifies the date format of the result, where 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        Current date string

datenum     Serial date number

datevec     Date components



[ Previous | Help Desk | Next ]