Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2011
    Posts
    5

    Unanswered: DB2 Current Date

    Hello all,
    I'm trying to pull the system date for last year and three previous years. To avoid putting parameters in, I'd like to program the dates in automatically. Here's the code I have so far:
    Code:
    WHERE (QO01ACCIDENT_YEAR BETWEEN '2008' AND '2010') AND (QO01SUBMIT_AGENCY_ORI = ? OR QO01MUNICIPALITY = ?)) AS SEVACC
    I'd like to select the years from the system as I said earlier to avoid having the user have to input parameters. I found the YEAR(CURRENT DATE) but it's not working for me. Does anyone have any suggestions. Please let me know if you need additional information. Thanks.
    Last edited by sathyaram_s; 04-02-11 at 12:33. Reason: corrected code tag

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    Do you get any errors while trying year(current date)?

    see if the following works:
    Code:
    between char(year(current date)) and char(year(current date - 3 years))
    Visit the new-look IDUG Website , register to gain access to the excellent content.

Posting Permissions

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