Time query for iseries function, Timestamp query for iseries function – IBM ISERIES SC41-5210-04 User Manual

Page 91

Advertising
background image

TIME Query for iSeries function

The TIME function returns a time from a value. The form is:

TIME ( expression )

The argument must be either a:
v Time
v Timestamp
v Valid character representation of a time

The result of the function is a time value. If the argument can be null, the result can be null. If the
argument is null, the result is null.
v If the argument is a timestamp, the result is the time part of the timestamp.
v If the argument is a time, the result is that time.
v If the argument is a character string, the result is the time represented by the character string.

Example:

TIME(TIMESTAMP) where TIMESTAMP = 1991-10-22-12.15.23.123456

The resulting value of TIME equals 12.15.23.

TIMESTAMP Query for iSeries function

The TIMESTAMP function returns a timestamp from a value or a pair of values. The form is:

TIMESTAMP ( expression

)

expression

The rules for the arguments depend on whether or not the second argument is specified.
v If only one argument is specified, it must be either a:

– Timestamp

– Valid character representation of a timestamp

– Character string of length 14

Note: A character string of length 14 must be a string of digits that represents a valid date and time in

the form yyyyMMddhhmmss where yyyy is the year, MM is the month, dd is the day, hh is the
hour, mm is the minute, and ss is the seconds.

v If both arguments are specified, the first argument must be a date or a valid character representation of

a date. The second argument must be a time or a valid character representation of a time.

The result of the function is a timestamp. If either argument can be null, the result can be null. If either
argument is null, the result is null.

If both arguments are specified, the result is a timestamp with the date specified by the first argument and
the time specified by the second argument. The microsecond part of the timestamp is zero.

If only one argument is specified and it is a timestamp, the result is that timestamp. If only one argument
is specified and it is a character string, the result is the timestamp represented by that character string.
The timestamp represented by a string of length 14 has a microsecond part of zero.

Example:

Chapter 5. Defining result fields in Query for iSeries

79

Advertising