Using Literal Date Formats

SQR enables you to specify date constants and date values in a special format that is recognized without the use of an edit mask. This is called the literal date format. For example, you can use a value in this format in the strtodate function without the use of an edit mask. This format is independent of any specific database or language preference.

The literal date format is SYYYYMMDD[HH24[MI[SS[NNNNNN]]]]. The first S in this format represents an optional minus sign. If preceded with a minus sign, the string represents a BC date. The digits that follow represent year, month, day, hours, minutes, seconds, and microseconds.

Note: The literal date format assumes a 24-hour clock.

You can omit one or more time elements from the right part of the format. A default is assumed for the missing elements. Here are some code examples:

let $a = strtodate('20040409')
let $a = strtodate('20040409152000')

The first LET statement assigns the date of April 9, 2004 to the $a variable. The default time portion is 00:00. The second LET statement assigns 3:20 in the afternoon of April 9, 2004 to $a. The outputs (when printed with the ‘DD-MON-YYYY HH:MI AM’ edit mask ) are, respectively:

09-APR-2004 12:00 AM
09-APR-2004 03:20 PM

You can also specify a date format with the SQR_DB_DATE_FORMAT environment variable. You can specify this as an environment variable or in the pssqr.ini file.