Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2007
    Posts
    66

    Unanswered: Urgent DB2 date conversion help

    Hi ,

    Can you tell me what is wrong with the following expression.I am unable to covert it to the date type.


    values DATE(CHAR(CAST((4+1) AS CHAR(2)) || '/01/' || CAST(YEAR(CURRENT_DATE) AS CHAR(4))))

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    It may help if you look at the result of VALUES CHAR(CAST((4+1) AS CHAR(2)) || '/01/' || CAST(YEAR(CURRENT_DATE) AS CHAR(4)))
    ---
    "It does not work" is not a valid problem statement.

  3. #3
    Join Date
    Jun 2007
    Posts
    66
    '5 /01/2007'


    Above is the result for the expression without date function..Any idea why the above result is not taken by DATE function??

    Thanks

  4. #4
    Join Date
    Jun 2007
    Posts
    66
    I understood the problem now..The day part was defined as char(2) and there was an unwanted space being inserted..Thanks for the reply

  5. #5
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    You can use RTRIM() to get rid of such spaces.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

Posting Permissions

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