DATE-TIME

Note:

This command may be discontinued in a future release. We highly recommend that you no longer use this command. To take advantage of newer Production Reporting functionality, use the datenow function in the LET command.

Function

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

Syntax

DATE-TIME  position [date_format[col_var]]

Arguments

position

The position for printing the date.

date_format

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.

Description

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

If a date_format is not specified, then the date is returned in the default format for that database.

Table 107. Default Date-Time Formats

Database

Default Date-Time Format

DB2

YYYY-MM-DD-HH:MI

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

Informix

YYYY-MM-DD HH:MI

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

Oracle

DD-Mon-YYYY  HH:MI PM

Sybase

DD-MON-YYYY HH:MI

For some databases, there are 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, as follows:

date-time () '' &date1

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

For information on the valid edit mask format codes, see Table 52, Miscellaneous Functions.

Examples

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