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 > Database Server Software > DB2 > DB2 QMF Date Calculations

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-29-09, 10:26
robin2325 robin2325 is offline
Registered User
 
Join Date: Sep 2009
Posts: 1
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.
Reply With Quote
  #2 (permalink)  
Old 09-29-09, 11:24
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
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
Reply With Quote
  #3 (permalink)  
Old 09-30-09, 01:07
umayer umayer is offline
Registered User
 
Join Date: Dec 2005
Posts: 273
try:

... WHERE customer_date > LAST_DAY ( current date ) + 1 DAY - 13 MONTH
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On