Using QMF

Isolating the day, month, or year portion of a date

The DAY function returns the day part of a value. The argument must be a date, timestamp, or a decimal number that is interpreted as a duration of years, months, or days. (For a complete description of durations, see Using durations to represent date/time intervals.) The following SQL statement produces a report showing on which day of the month an interview occurs:

SELECT TEMPID, DAY(INTDATE)
  FROM Q.INTERVIEW
  WHERE MANAGER = 270

This report shows that the interviews take place on the fifth day of the month:

+--------------------------------------------------------------------------------+
|              DAY OF                                                            |
|   TEMPID      MONTH                                                            |
|   ------  ---------                                                            |
|      400          5                                                            |
|      470          5                                                            |
+--------------------------------------------------------------------------------+

The MONTH function returns the month part of a value. The argument must be a date, timestamp, or a decimal number that is interpreted as a duration of years, months, or days. The following SQL statement produces a report showing on which month of the year an interview occurred:

SELECT MANAGER, DISP, MONTH(INTDATE)
  FROM Q.INTERVIEW

This report shows the months in which certain managers interviewed prospective employees and the disposition of each interview.

+--------------------------------------------------------------------------------+
|   MANAGER  DISP          MONTH                                                 |
|   -------  ------  -----------                                                 |
|       270  NOHIRE            2                                                 |
|        10  HIRE              2                                                 |
|       140  HIRE              4                                                 |
|       290  NOHIRE            4                                                 |
|       160  HIRE              3                                                 |
|        50  HIRE              9                                                 |
|       100  HIRE             10                                                 |
|       270  HIRE              2                                                 |
|       160  NOHIRE            3                                                 |
|       140  NOHIRE            9                                                 |
+--------------------------------------------------------------------------------+

The YEAR function returns the year part of a value. YEAR works like DAY and MONTH. The argument must be a date, timestamp, or a decimal number that is interpreted as a duration of years, months, or days. When you run the following SQL statement:

SELECT PROJNO, YEAR(ENDD)
  FROM Q.PROJECT
  WHERE PRODNUM = 190

QMF produces this report:

+--------------------------------------------------------------------------------+
|              YEAR OF                                                           |
|   PROJNO   COMPLETION                                                          |
|   ------  -----------                                                          |
|   1404           1999                                                          |
|   1410           2000                                                          |
+--------------------------------------------------------------------------------+

This report shows the year of project end dates for a given product. It disregards the day and month.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]