Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2010
    Location
    Tacoma, Wa
    Posts
    3

    Unanswered: Add months to a date of type int with format YYYYMMDD

    I am using db2 UDB400.
    I am querying the transaction date, which is of Type INT formatted as YYYYMMDD. I need to add ex. 6 months to this date, then divide by 6 to get AVG usage for 6 months.
    Ideally, if I can just add months to this format, I can change the months out to a parameter in Crystal reports.
    Any help is greatly appreciated!

    Luke

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    I need to add ex. 6 months to this date,
    Although I don't know so much about DB2 for iSeries,
    I don't think that you can add months to INT value directly.

    An idea I thought was ...
    1) Convert the INT value to a valid date string.
    2) CAST the string to date.
    3) Add months.

    Here is a sample expression.
    DATE( TRANSLATE( 'abcd-ef-gh' , DIGITS(transaction_date) , '..abcdefgh' ) ) + 6 MONTHs

    then divide by 6 to get AVG usage for 6 months.
    I couldn't understand it.
    divide WHAT by 6?
    "divide date by something" may be nonsense.

Tags for this Thread

Posting Permissions

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