Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Convert timestamp to yyyy-mm-dd format

1,139 views
Skip to first unread message

yogi

unread,
Feb 7, 2008, 9:03:51 PM2/7/08
to
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

unread,
Feb 7, 2008, 9:25:39 PM2/7/08
to
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

Toralf Förster

unread,
Feb 8, 2008, 4:28:15 AM2/8/08
to
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


netzorro

unread,
Feb 8, 2008, 9:25:17 PM2/8/08
to
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',MONTH(fec)*3-2,3) || '-' ||
SUBSTR(DIGITS(YEAR(fec)),7,4);
END

Diego


"yogi" <yog...@gmail.com> wrote in message
news:d512b805-60a2-4ea7...@i7g2000prf.googlegroups.com...

zbin...@gmail.com

unread,
Sep 19, 2015, 1:31:40 AM9/19/15
to
you can try this free online timestamp converter(http://www.online-code.net/unix-timestamp.html) to convert timestamp to readable date.

--CELKO--

unread,
Sep 19, 2015, 3:12:13 PM9/19/15
to
> Some time ago I had to write a function to create a special format for dates
> in Spanish like dd-mmm-yyyy

Please do not do this. You should follow ISO-8601 rules for displaying temporal data. Read https://xkcd.com/1179/ to see the point of standards and to get a laugh.
0 new messages