Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2007
    Posts
    31

    Unanswered: 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

  2. #2
    Join Date
    Jan 2003
    Posts
    4,292
    Provided Answers: 5
    try YEAR(current date - 1 month)

    Andy

  3. #3
    Join Date
    Apr 2007
    Posts
    31
    BINGO! Thanks!
    cdun2

Posting Permissions

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