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 > Getting YEAR as of prior month

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-17-07, 12:13
cdun2 cdun2 is offline
Registered User
 
Join Date: Apr 2007
Posts: 31
Getting YEAR as of prior month

Hello,
In DB2 syntax, how would I extract the YEAR from a date column where I'm interested in the year of the previous month? In SQL Server syntax I would do it like this;

YEAR(DATEADD(MONTH,-1,GETDATE()))

From what I can tell, there is no equivalent DATEADD function available in DB2, and I must use CURRENT_DATE instead of GETDATE().

This is something I'm trying to do in SQL Server DTS where the source table is coming from a DB2 system.

Thank you for your help!

cdun2
Reply With Quote
  #2 (permalink)  
Old 05-17-07, 12:42
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
try YEAR(current date - 1 month)

Andy
Reply With Quote
  #3 (permalink)  
Old 05-17-07, 14:12
cdun2 cdun2 is offline
Registered User
 
Join Date: Apr 2007
Posts: 31
BINGO! Thanks!
cdun2
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