Extract Date and Time elements
The Extract Date and Time elements command extracts years, months, days, hours, minutes and seconds from a variable containing this information in a text format. This information is stored in separate variables allowing the user to use all components of the date as the user pleases.
Parameters
- DateTime - Text variable containing the date and time information
- Year - Numerical variable that will be used to store the current year
- Month - Numerical variable that will be used to store the current month
- Day - Numerical variable that will be used to store the current day
- Hour - Numerical variable that will be used to store the current hour
- Minute - Numerical variable that will be used to store the current minute
- Second - Numerical variable that will be used to store the current second
Comments
This command is very useful in combination with the command “Format Local Time”.
Example
Extract Date and Time elements lcl_txt, lcl_year, lcl_month, lcl_day, lcl_hour, lcl_min, lcl_sec
This example shows the extraction of date and time elements from the variable lcl_txt. The other variables are named in such a way that it is clear what they are used for.
It is quite easy to construct a date or time from these separate variables. See the example below:
SET gbl_date_txt = lcl_day+"/"+lcl_month+"/"+lcl_year
This examples shows the construction of a date in a format like “1/1/2010” by combining the different numerical variables with the / character into the correctly formatted date.