Using QMF

Accounting for months with different numbers of days

Because of inconsistencies in the number of days in the months of the year, adding a month to a given date does not always result in the same day of the next month. The result of adding one month to January 31 cannot be February 31. Adding a month to a given date results in the same day of the next month when such a day exists. If it does not exist, adding a month to a given date results in the last day of the next month. For example, if you add one month to January 31, the result is February 28 (or February 29 in a leap year).

To avoid inconsistencies in date arithmetic that is caused by months, use days. For example, to increment a date by the difference between two dates, you can use an SQL statement like this:

SELECT DATE(DAYS('1988-01-05') + DAYS(ENDD) - DAYS(STARTD))
  FROM Q.PROJECT
  WHERE PROJNO = '1408'

QMF produces this report:

+--------------------------------------------------------------------------------+
|   COL1                                                                         |
|   ----------                                                                   |
|   1989-07-25                                                                   |
+--------------------------------------------------------------------------------+


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