469,366 Members | 2,198 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,366 developers. It's quick & easy.

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
Feb 8 '08 #1
3 49821
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
Feb 8 '08 #2
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_name, '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
Feb 8 '08 #3
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(DAY(fec)),9,2) || '-' ||
SUBSTR('EneFebMarAbrMayJunJulAgoSepOctNovDic',MONT H(fec)*3-2,3) || '-' ||
SUBSTR(DIGITS(YEAR(fec)),7,4);
END

Diego


"yogi" <yo*****@gmail.comwrote in message
news:d5**********************************@i7g2000p rf.googlegroups.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

Feb 9 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Manzoorul Hassan | last post: by
4 posts views Thread by Prakash | last post: by
8 posts views Thread by Chris | last post: by
4 posts views Thread by Dean Slindee | last post: by
10 posts views Thread by David Garamond | last post: by
10 posts views Thread by satishrajana | last post: by
3 posts views Thread by Jonathan | last post: by
reply views Thread by sloan | last post: by
4 posts views Thread by Tim Kelley | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.