If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > JAVA > DB2 Current Date

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-29-11, 10:35
db2mo db2mo is offline
Registered User
 
Join Date: Mar 2011
Posts: 5
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 11:33. Reason: corrected code tag
Reply With Quote
  #2 (permalink)  
Old 04-02-11, 11:49
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,536
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On