Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2002
    Posts
    4

    Thumbs up Unanswered: Date conversion question

    Hi,
    I am new to DB2 have a query regarding DB2 date functions. I have two colums with date data that are stored as decimal and char.

    I want to covert the decimal/char column to date type and change Current date function format to ccyy/mm/dd in order to select records that are older than 30 days for example.

    delete from table where decimal_date_col < (currentdate - 30 days) in CCYYMMDD format

    (PS: decimal_date_col is a decimal data type)

    In Oracle I used to_char with a format mask and sysdate minus number of days.


    I have tried using char and date function to convert the date but get the following error

    I get following errors
    SQL0183N A datetime arithmetic operation or a datetime scalar function has aresult that is not within the valid range of dates. SQLSTATE=22008


    Thanks for help in advance

  2. #2
    Join Date
    Apr 2002
    Posts
    188

    Re: Date conversion question

    Originally posted by tzp2ft
    Hi,
    I am new to DB2 have a query regarding DB2 date functions. I have two colums with date data that are stored as decimal and char.

    I want to covert the decimal/char column to date type and change Current date function format to ccyy/mm/dd in order to select records that are older than 30 days for example.

    delete from table where decimal_date_col < (currentdate - 30 days) in CCYYMMDD format

    (PS: decimal_date_col is a decimal data type)

    In Oracle I used to_char with a format mask and sysdate minus number of days.


    I have tried using char and date function to convert the date but get the following error

    I get following errors
    SQL0183N A datetime arithmetic operation or a datetime scalar function has aresult that is not within the valid range of dates. SQLSTATE=22008


    Thanks for help in advance
    Hello do a search on date functions within this forum, I have seen implementations of what you want and samples here..

    marcos oliva

  3. #3
    Join Date
    Oct 2002
    Location
    Pune (India)
    Posts
    9
    Use LOCATE function to get the desired format of Date
    Sujit

Posting Permissions

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