Isolating the hour, minute, second, or microsecond portion of a time

The HOUR function returns the hour part of a value. The argument must be a time, timestamp, or a decimal number that is interpreted as a time. When you run the following SQL statement:

SELECT TEMPID, ENDTIME
  FROM Q.INTERVIEW
  WHERE TEMPID = 400

QMF produces this report:

   TEMPID  ENDTIME
   ------  --------
      400  15.12.00

ENDTIME shows hours, minutes, and seconds. For example, when you run this SQL statement:

SELECT TEMPID, HOUR(ENDTIME)
  FROM Q.INTERVIEW
  WHERE TEMPID = 400

QMF produces this report, which shows only the hour portion of ENDTIME:

                ENDING
   TEMPID        HOUR
   ------  -----------
      400           15

The MINUTE function returns the minute part of a value. The argument must be a time, timestamp, or a decimal number that is interpreted as a duration of hours, minutes, or seconds.

When you run the following SQL statement:

SELECT TEMPID, MINUTE(ENDTIME)
  FROM Q.INTERVIEW
  WHERE TEMPID = 400

QMF produces this report:

                ENDING
   TEMPID       MINUTE
   ------  -----------
      400           12

The SECOND function returns the seconds part of a value. The argument must be a time, timestamp, or a decimal number that is interpreted as a duration of hours, minutes, or seconds. For example, when you run the following SQL statement:

SELECT TEMPID, SECOND(ENDTIME)
  FROM Q.INTERVIEW
  WHERE TEMPID = 400

QMF produces this report:

                ENDING
   TEMPID       SECOND
   ------  -----------
      400            0

The MICROSECOND function returns the microsecond part of a value. The argument can be only a timestamp. For example, when you run the following SQL statement:

SELECT PROJNO, MICROSECOND(TIMESTAMP)
  FROM Q.PROJECT
  WHERE PROJNO = '1409'

QMF produces this report:

   PROJNO         COL1
   ------  -----------
   1409         149572
[ Previous Page | Next Page | Contents | Index ]