DT_TO_STR Procedure

Converts date/time variables to string data.

Usage

    DT_TO_STR, dt_var, [, dates] [, times]

Input Parameters

dt_var — Date/time variable containing one or more date/time structures.

Output Parameters

dates — (optional) A variable containing the date strings extracted from the date/time variable.

times — (optional) A variable containing the time strings extracted from date/time variable.

Keywords

Date_Fmt — Specifies the format of the date data in the input variable. Possible values are 1, 2, 3, 4, or 5, as summarized in Values for Date_Fmt:

Values for Date_Fmt

Value

Format Description

Examples for May 1, 1992

1

MM*DD*YYYY

05/01/1992

2

DD*MM*YYYY

01-05-1992

3

ddd*YYYY

122,1992

4

DD*mmm[mmmmmm]*YYYY

01/May/1992

5

YYYY*MM*DD

1992-05-01

where the asterisk (*) represents one of the following separators: dash (–), slash (/), comma (,), period (.), or colon (:).

Time_Fmt — Specifies the format of the time portion of the data in the input variable. Possible values are –1 or –2, as summarized in Values for Time_Fmt:

Values for Time_Fmt

Value

Format Description

Examples for 1:30 p.m.

–1

HH*Mn*SS.sss

13:30:35.25

–2

HHMn

1330

where the asterisk (*) represents one of the following separators: dash (–), slash (/), comma (,), or colon (:). No separators are allowed between hours and minutes for the –2 format. Both hours and minutes must occupy two spaces.

Date and time separators are specified with the !Date_Separator and !Time_Separator system variables. It is possible to use any character or string as a separator with the DT_TO_STR function; however, if you use a non-standard separator (one other than dash (–), slash (/), comma (,), period (.), or colon (:)), you will be unable to convert the data back to a date/time variable with STR_TO_DT. If Either of these system variables is set to an empty string, then you receive a default separator.

You must specify a date and/or time format if the dates and/or times parameters are specified.

Examples

Assume you have a date/time variable named date1 that contains the following date/time structures:

date1=[{!dt, 1992,3,13,1,10,34.0000,87474.049,0}, $
       {!dt, 1983,4,20,16,18,30.0000,84224.680,0}, $
       {!dt, 1964,4,24,5,7,25.0000,77289.213,0}]
; To convert to string data, use the DT_TO_STR procedure.
; Convert date/time data. Store the date data in d and
; the time data in t.
DT_TO_STR, date1, d, t, Date_Fmt=1, Time_Fmt=-1
PRINT, d
; PV-WAVE prints: 3/13/1992 4/20/1983 4/24/1964
PRINT, t
; PV-WAVE prints: 01:10:34.000 16:18:30.000 05:07:25.000

See Also

DT_TO_SEC, DT_TO_VAR, STR_TO_DT

System Variables: !Date_Separator, !Time_Separator

For more information on date/time, see the PV‑WAVE User Guide.