Convert timestamp to yyyy-mm-dd format

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • yogi

    Convert timestamp to yyyy-mm-dd format

    Hi,
    I am working on a database that has a variable with timestamp
    values. I wanted to convert the variable from timestamp to yyyy-mm-dd
    format.

    Thanks in advance

    Yogi
  • Serge Rielau

    #2
    Re: Convert timestamp to yyyy-mm-dd format

    yogi wrote:
    Hi,
    I am working on a database that has a variable with timestamp
    values. I wanted to convert the variable from timestamp to yyyy-mm-dd
    format.
    db2 =VALUES SUBSTR(VARCHAR( CURRENT TIMESTAMP), 1, 10);

    1
    ----------
    2008-02-07

    1 record(s) selected.

    --
    Serge Rielau
    DB2 Solutions Development
    IBM Toronto Lab

    Comment

    • Toralf =?utf-8?q?F=C3=B6rster?=

      #3
      Re: Convert timestamp to yyyy-mm-dd format

      yogi wrote:
      Hi,
      I am working on a database that has a variable with timestamp
      values. I wanted to convert the variable from timestamp to yyyy-mm-dd
      format.
      select
      varchar_format (your_column_na me, 'YYYY-MM-DD HH24:MI:SS')
      from
      your_table

      and for an export statement use sth like

      EXPORT TO my_file OF DEL MODIFIED BY COLDEL;
      TIMESTAMPFORMAT =\"dd.mm.yyyy hh:mm\"
      select * from foo


      --
      Toralf Förster
      pgp key 0x7DB69DA3


      Comment

      • netzorro

        #4
        Re: Convert timestamp to yyyy-mm-dd format

        Some time ago I had to write a function to create a special format for dates
        in spanish like dd-mmm-yyyy

        I'm sure you can adapt this to get the function you need

        CREATE FUNCTION FFF.DATE3( fec DATE )
        RETURNS varchar(11)
        ------------------------------------------------------------------------
        -- SQL UDF (Scalar)
        ------------------------------------------------------------------------
        F1: BEGIN ATOMIC
        RETURN SUBSTR(DIGITS(D AY(fec)),9,2) || '-' ||
        SUBSTR('EneFebM arAbrMayJunJulA goSepOctNovDic' ,MONTH(fec)*3-2,3) || '-' ||
        SUBSTR(DIGITS(Y EAR(fec)),7,4);
        END

        Diego




        "yogi" <yogibad@gmail. comwrote in message
        news:d512b805-60a2-4ea7-94df-20da3468e957@i7 g2000prf.google groups.com...
        Hi,
        I am working on a database that has a variable with timestamp
        values. I wanted to convert the variable from timestamp to yyyy-mm-dd
        format.
        >
        Thanks in advance
        >
        Yogi

        Comment

        Working...