Results 1 to 5 of 5
  1. #1
    Join Date
    May 2009
    Posts
    3

    Unanswered: very urgent Plz provide solution ASP

    hello all,

    i have a string 'Apr 19 20:00:03 CDT 2009' which i need to convert in to date does DB2 have any function to do it?

  2. #2
    Join Date
    May 2009
    Posts
    508
    Provided Answers: 1
    raj0390, It would help if you list the DB2 and version (along with operating system) so the appropriate answer can be supplied (i.e. some functions are in DB2 z/OS but not LUW).

    However, I don't believe any DB2 has a function to convert that string into a Timestamp. At least not directly.

    If you format is identical in all cases, you can try to parse out the information and build a timestamp string. For example

    SUBSTR('TS-STRING',21,4) || '-' || CASE SUBSTR('TS-STRING',1,3) WHEN 'Jan' THEN '01'
    WHEN 'Feb' THEN 02
    etc.
    end
    || '-' || SUBSR(you get the idea I hope).

    PS TS-STRING is the character timestamp string you have in your post. I didn't want to type all that in the example.

  3. #3
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    You should also tell us whether you need a timestamp or a date value.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  4. #4
    Join Date
    May 2009
    Posts
    3

    very urgent Plz provide solution ASP

    i just need the date value

  5. #5
    Join Date
    May 2009
    Posts
    3
    Quote Originally Posted by Stealth_DBA
    raj0390, It would help if you list the DB2 and version (along with operating system) so the appropriate answer can be supplied (i.e. some functions are in DB2 z/OS but not LUW).

    However, I don't believe any DB2 has a function to convert that string into a Timestamp. At least not directly.

    If you format is identical in all cases, you can try to parse out the information and build a timestamp string. For example

    SUBSTR('TS-STRING',21,4) || '-' || CASE SUBSTR('TS-STRING',1,3) WHEN 'Jan' THEN '01'
    WHEN 'Feb' THEN 02
    etc.
    end
    || '-' || SUBSR(you get the idea I hope).

    PS TS-STRING is the character timestamp string you have in your post. I didn't want to type all that in the example.


    thx mate, for your time

Posting Permissions

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