User Guide > Working with Date/Time Data > Miscellaneous Date/Time Utility Functions
  

Miscellaneous Date/Time Utility Functions
PV‑WAVE contains several utilities for generating and obtaining information about date/time variables. For more information about each of these functions, see the PV‑WAVE Reference. These include:
*TODAY
*DAY_NAME
*DAY_OF_WEEK
*MONTH_NAME
*DAY_OF_YEAR
*DT_PRINT
TODAY Function
This function returns a date/time variable containing the current date and time. The form of the function is:
result = TODAY 
Example
dttoday = TODAY()
PRINT, dttoday
; PV-WAVE prints: { 1992 3 26 7 11 14.0000 87487.299 0}
DAY_NAME Function
This function returns a string variable or array of string variables containing the name(s) of the day(s) of the week of the date(s) in the input variable. The form of the function is:
result = DAY_NAME(dt_var) 
Example
Assume that you have a date/time variable, date, for April 13, 1992. To find out which day of the week this date is, enter:
day = DAY_NAME(date)
PRINT, day
; PV-WAVE prints: Monday
The day names are accessed from the !Day_Names system variable.
DAY_OF_WEEK Function
This function returns the day(s) of the week expressed as an integer(s) for a date/time variable. Day 0 is Sunday, 1 is Monday, etc. The syntax of the function is:
result = DAY_OF_WEEK(dt_var) 
Example
Assume that you have a date/time variable, date, for April 13, 1992. To find out which day of the week this date is, enter:
day = DAY_OF_WEEK(date)
PRINT, day
; PV-WAVE prints: 1
A value of 1 indicates it is a Monday.
MONTH_NAME Function
This function returns a string or array of strings containing the month name of dt_var, where dt_var is a date/time variable. The function has the form:
result = MONTH_NAME(dt_var) 
Example
Create variable that contains date/time data for today's date.
dttoday = TODAY()
; PV-WAVE prints: { 1992 4 1 6 12 57.0000 87493.259 0}
m = MONTH_NAME(dttoday)
PRINT, m
; PV-WAVE prints: April
The month names are accessed from the system variable !Month_Names.
DAY_OF_YEAR Function
This function returns an integer or array of integers representing the day number of the year for each date/time value. Day numbers fall in a range between 1 and 365 (or 366 for a leap year). The syntax of the function is:
result = DAY_OF_YEAR(dt_var) 
Example
; Create a date/time variable.
dttoday = TODAY()
daynumber = DAY_OF_YEAR(dttoday)
PRINT, daynumber
; PV-WAVE prints: 106
DT_PRINT Procedure
This procedure takes the values in a date/time variable and prints these values in a readable manner. The procedure has the form:
DT_PRINT, dt_var
dttoday= TODAY()
DT_PRINT, dttoday
; PV-WAVE prints: 4/2/1992 7:7:51.0000

Version 2017.1
Copyright © 2019, Rogue Wave Software, Inc. All Rights Reserved.