Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2006
    Posts
    2

    Unanswered: Any clever way to convertChar to Date?

    Hi All,

    I would like to convert a date in char type with the format 'dd/mm/yyyy' (eg. 30/01/2006) into date datatype before inserting into the table.

    instead of substring the char into day, month and year, Is there any faster way to do that?

    Thank you very much.

  2. #2
    Join Date
    Jun 2006
    Posts
    471

    to date

    can this not be used ?
    TO_DATE--(--string-expression--,format-string--)----
    Best Regards, Guy Przytula
    DB2 UDB LUW certified V6/7/8

  3. #3
    Join Date
    Jul 2005
    Posts
    2

    Date to Char

    Hi,

    You can convert date to character using te function to_char.

    Example: to_char(sysdate, 'DD-MON-YYYY') will return the date in ther format DD-MON-YYYY like 01-JAN-2006.

    rgds,
    Uday

  4. #4
    Join Date
    Dec 2004
    Posts
    7

    Date Conversion

    Hi, Victor,

    I believe this would solve your little puzzle:

    db2 values date ( replace ('30/01/2006','/', '.'))

    1
    ----------
    01/30/2006

    1 record(s) selected.

    Of course, you could have your application substitute the slashes by periods and submit the string to the DATE function directly!

    Hope this helps,

    Willy



    Quote Originally Posted by victorlung
    Hi All,

    I would like to convert a date in char type with the format 'dd/mm/yyyy' (eg. 30/01/2006) into date datatype before inserting into the table.

    instead of substring the char into day, month and year, Is there any faster way to do that?

    Thank you very much.

Posting Permissions

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