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 > Same day last year

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-04-09, 13:53
bavirisetty bavirisetty is offline
Registered User
 
Join Date: Sep 2009
Posts: 4
Same day last year

Can someone pls help me with the DB2 code how to acheive the following result:

THIS_YEAR LAST_YEAR
--------------------- ---------------------
Wed 10 June 2009 Wed 11 June 2008


I am looking at Same DAY of the last year not the date.

Thanks,
Guru.
Reply With Quote
  #2 (permalink)  
Old 09-04-09, 14:14
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Try:

values current date - 1 year + dayofweek(current date) days - dayofweek(current date - 1 year) days

Andy
Reply With Quote
  #3 (permalink)  
Old 09-04-09, 14:24
bavirisetty bavirisetty is offline
Registered User
 
Join Date: Sep 2009
Posts: 4
Same Day last year

select dy.DAY_DT TY_DT,
dayname(dy.DAY_DT) as TY_DAY
from PROD_DY dy

Here is the code as of now. Can you please add a column to this statement which will contain the previous year same day. I really appreciate all your help.
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