VAR_TO_DT Function
Converts scalar or array values representing dates and times to date/time variables.
Usage
result = VAR_TO_DT(yyyy, mm, dd, hh, mn, ss)
Input Parameters
yyyy—A scalar or array containing year numbers.
mm—A scalar or array containing month numbers (1–12).
dd—A scalar or array containing day numbers (1 – 31).
hh—A scalar or array containing hour numbers (0 – 23). If zero or not specified, hh is 0 hours.
mn—A scalar or array containing minute numbers (0 – 59). If zero or not specified, mn is 0 minutes.
ss—A scalar or array containing second numbers (0.0000 –59.9999). If zero or not specified, ss is 0.0 seconds.
Returned Value
result—A date/time variable containing the converted values.
Keywords
None.
Discussion
Use this function to create date/time variables from time stamp data that does not conform to a format used by the STR_TO_DT function. For example, you can read the date and time data into atomic variables representing each of the date and time elements (i.e., year, month, day, etc.). Then the variables can be converted to date/time variables using VAR_TO_DT.
If the year, month, and day values are all zero, then the value of the !DT_Base system variable is used for the date portion of the resulting date/time variable.
The parameters can be arrays of any numeric values, but all parameters must have the same dimension; that is, the parameters must be either all scalars or all arrays of the same size. Also you can only omit parameters from the end of the parameter list.
Example 1
This example illustrates how to convert a single date value into date/time variable.
; Note that seconds have been omitted. This command creates a
; date/time variable containing November 22, 1992 at 12:30.
z = VAR_TO_DT(1992, 11, 22, 12, 30)
PRINT, z
; PV-WAVE prints: { 1992 11 22 12 30 0.00000 87728.521 0}
DT_PRINT, z
; PV-WAVE prints: 11/22/1992 12:30:00.000
Example 2
This example illustrates how to return a date/time variable for an array containing values representing dates.
; Create arrays that contain date/time information for two days.
years = [1992,1993]
months = [3,4]
days = [17,18]
; Convert the date/time arrays to a date/time structure variable.
y = VAR_TO_DT(years, months, days)
DT_PRINT, y
; PV-WAVE prints the following:
; 03/17/1992
; 04/18/1993
See Also
For more information, see the PV‑WAVE User’s Guide.