DATE-TIME

You should no longer use this command because it may be discontinued in a future release. To use the newer SQR functionality, use the datenow function in the LET command.

Syntax

Use this syntax:

DATE-TIME  position [date_format[col_var]]

Description

Retrieves the current date and time from the local machine (or from the database for Oracle and some IBM DB2 platforms) and places it in the output file at the specified position or into a column variable.

If col_var is specified, then date_format must be supplied and the current date and time is retrieved each time this command is run. Otherwise, the date is retrieved only at the program start, and the same date and time is printed each time.

If date_format is not specified, the date is returned in the default format for that database. The following table provides the default date-time formats for SQR-supported databases:

Database Default Date-Time Format

Oracle

DD-Mon-YYYY  HH:MI PM

IBM DB2

YYYY-MM-DD-HH:MI YYYY-MM-DD- HH:MI:SS.NNNNNN

Some databases have two default formats. The first format prints the date-time, as in the following example:

date-time (+1,1)

The second format retrieves the date-time into a column variable:

date-time () '' &date1

For databases with only one default format, that format is always used in either of these cases.

See the table showing miscellaneous functions under the LET command for information about the valid edit mask format codes.

Parameters

Field or Control Description

position

Specifies the position for printing the date.

date_format

Represents a string literal containing the date format mask.

col_var

Places the retrieved date-time into a column variable rather than in the output file.

Example

For example:

date-time (1,50)  MM/DD/YY
date-time (1,1) 'Day Mon DD, YYYY'
date-time ()  HH:MI  &time
date-time (+1,70) 'MON DD YYYY HH24:MI' &datetime
date-time (#i, #j) 'YYYY-MM-DD' &date1

See the $current-date reserved and datenow functions that are described in the table showing miscellaneous functions under the LET command.

See ALTER-LOCALE.