STR_TO_DT

The STR_TO_DT function converts date and time string data to date/time values. The result is a IDLDT date/time structure containing the converted IDLDT date/time data.

You can convert only date strings, only time strings, or both date and time strings. The date portion of the date/time structure defaults to the value in the system variable !DT_BASE. The time portion of the resulting date/time variable defaults to zero.

Calling Sequence

Result = STR_TO_DT( Dates [, Times] )

Arguments

Dates

A string constant or string array containing date strings.

Times

A string constant or string array containing time strings.

Keywords

DATE_FMT

Set this keyword to specify the format of the date portion of the data in the input string variable. The possible date format values are:

  • Date Format Values for the STR_TO_DT function

Value

Format Description

Examples for October 8, 1969

1

MM*DD*[YY]YY

10/08/69

2

DD*MM*[YY]YY

08-10-69

3

ddd*[YY]YY

281,1969

4

DD*mmm[mmmmmm]*[YY]YY

08/Oct/69

5

[YY]YY*MM*DD

1969-10-08

The asterisk, *, may represent any of the following separators: " - ", " / ", " , ", " . ", " : ". The default is Value 1.

TIME_FMT

Set this keyword to specify the format of the time portion of the data in the input variable. The possible time format values are:

  • Time Format Values for the STR_TO_DT function

Value

Format Description

Examples for 2:30 p.m.

-1

HH*Mn*SS[.SSSS]

14:30:00.00

-2

HHMn

1430

The asterisk, *, represents one of the following separators: " - ", " / ", " , ", " : ".
No separators are allowed between hours and minutes for the -2 value. Both hours and minutes must occupy two spaces. The default is the -1 value.

Example

dates =['14-Dec-1948','18-May-1943','29/Dec/1970','14/July/1971']

times = ['9:00:00', '6:00:00', '10:00:00', '5:00:00']

date_dt = STR_TO_DT(dates, times, DATE_FMT = 4)
; Creates an array of three dates. By default, TIME_FMT = -1.

See Also

IDLDT__DEFINE