Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2009

    Unanswered: DB2 QMF Date Calculations

    I'm trying to extract records from a table for all customers that have a date greater than 12 months ago, but it must be the first of that month. For example, if today is 09/29/2009, I want all customers with a start date greater than 09/01/2008. I know how to get customers with dates greater than 12 months ago, but don't know how to get to the first of the month. I'm using QMF.

  2. #2
    Join Date
    May 2003
    This query against the employee table in the sample database works on DB2 LUW, but should work on mainframe also:

    select * from employee where hiredate >= substr(char((current_date - 1 years),iso),1,7)||'-01'
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  3. #3
    Join Date
    Dec 2005

    ... WHERE customer_date > LAST_DAY ( current date ) + 1 DAY - 13 MONTH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts