Converting text to date/time types
- A text expression (variable, literal, etc.) is assigned or compared to a date/time variable.
- A user enters text in an input field specified with a date/time type.
Converting text to date
EGL uses the strlib.defaultDateFormat system variable to interpret the text. The conversion algorithm is tolerant of different or missing separators but will take the order of year, month, and day of month from the default format.
- Use the dateTimeLib.dateValueFromGregorian() function to convert text values to DATE values. See dateValueFromGregorian().
- Specify a date format for DATE type input fields.
Converting text to time
EGL uses the strlib.defaultTimeFormat system variable to interpret the text. EGL looks for the fields in order of hours, minutes, and seconds, permitting any separators between them.
If you cannot be sure of the setting of the defaultTimeFormat, you can specify a time format for TIME type input fields to make sure that your program always converts the specified values in the same way.
Converting text to timestamp
EGL uses the strlib.defaultTimestampFormat system variable to interpret the text. If that fails, EGL looks for the timestamp fields in order from largest to smallest, permitting any separators between them.
- Use the dateTimeLib.timestampValueWithPattern() function to convert text values to TIMESTAMP values.
- Specify a timestamp format for TIMESTAMP type input fields.
Converting text to interval
EGL performs the conversion for the interval fields in order from largest to smallest, permitting any separators between them. The text may optionally begin with a leading + or -.
Example
myDate = "aaa2006aa01a02222aa";Using
the pattern of four digits for the year, followed by two digits each
for the month and the day, EGL parses the string into the following
groups of digits: 2006 01 02 Finally, EGL
returns the complete DATE value: 2006/01/02myDate = "aa20051aa02222aa"; In
this case, EGL uses the same pattern of digits for the year, month,
and day, but the second group of digits is cut short by a non-digit
character. EGL parses the string into the following groups of digits:
2005 1 02Finally, EGL returns the complete
DATE value: 2005/01/02