Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2013
    Posts
    11

    Unanswered: date conversion in db2

    //Hi All please help me on date format conversion in db2. i am sending you db2 code please resolve the code error, actualy i am not getting Timestamp return type.

    CREATE or Replace FUNCTION TestPmcDate (timestamp_in VARCHAR(30))
    RETURNS TIMESTAMP
    LANGUAGE SQL
    Contains SQL
    DETERMINISTIC
    NO EXTERNAL ACTION
    Begin Atomic


    if timestamp_in ='MM-DD-YYYY HH24:MIS AM' Then
    --TIMESTAMP(yyyy||mm||dd||hh||mi||ss);
    VALUES( SUBSTR(timestamp_in, 1, 2),
    SUBSTR(timestamp_in, 4, 2),
    SUBSTR(timestamp_in, 7, 4),
    SUBSTR(timestamp_in, 12, 2),
    SUBSTR(timestamp_in, 15, 2),
    SUBSTR(timestamp_in, 18, 2),
    SUBSTR(timestamp_in, 21, 2));
    End if;




    --SELECT
    --CASE
    --WHEN UCASE(format) = 'MM/DD/YYYY@HH24:MIS' THEN
    --TIMESTAMP(yyyy||mm||dd||hh||mi||ss)
    --WHEN UCASE(format) = 'MM-DD-YYYY' or UCASE(format) = 'MM/DD/YYYY' THEN
    --TIMESTAMP(yyyy||mm||dd||'000000')

    Return timestamp_in;
    END
    --From Proposal



    Thanks & Regards
    Dharmendra

  2. #2
    Join Date
    Apr 2006
    Location
    Belgium
    Posts
    2,514
    Provided Answers: 11
    all info can be found at infocenter
    Date and time formats by territory code - IBM DB2 9.7 for Linux, UNIX, and Windows
    many samples are provided in samples directory of db2
    Best Regards, Guy Przytula
    Database Software Consultant
    Good DBAs are not formed in a week or a month. They are created little by little, day by day. Protracted and patient effort is needed to develop good DBAs.
    Spoon feeding : To treat (another) in a way that discourages independent thought or action, as by overindulgence.
    DB2 UDB LUW Certified V7-V8-V9-V9.7-V10.1-V10.5 DB Admin - Advanced DBA -Dprop..
    Information Server Datastage Certified
    http://www.infocura.be

Posting Permissions

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