473,394 Members | 1,640 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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 52323
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Manzoorul Hassan | last post by:
I need to convert a date / time to NTP Timestamp, in HEX no less, and was wondering if there might be a module for it. Any ideas? I have been searching for NTP Timestamp under Perl but have not...
4
by: Prakash | last post by:
Hi Can anyone tell me how to derive "yyyy" from a timestamp column in db2? Something like to_char(sysdate, 'yyyy') ... in oracle. I have to oracle-like to_char function but its very slow. If...
8
by: Chris | last post by:
Sorry, This should be simple, but brain is hurting... How do I convert a Current Time to a Decimal 6,0 (HMS)? There must be a cleaner way then this: Insert into Table Values Dec(...
4
by: Dean Slindee | last post by:
I have a timestamp field that I would like to display in a textbox. The timestamp is an 8 byte array. Can this be converted to a string in one statement or does it require cycling thru one byte...
10
by: David Garamond | last post by:
The Postgres manual says: The AT TIME ZONE construct allows conversions of time stamps to different time zones. I'd guess most people would think what's meant here is something like "unit...
10
by: satishrajana | last post by:
Hi, My SQL returns a NULL in a datefield if there is no date in that field. If there is a NULL in this column, I want to replace it with spaces in my SELECT statement when I am selecting these...
1
by: sebasC | last post by:
the code below is used on a site to show time in multiple time zones on the website what i need is to convert the php code below to asp so that it will work. because the clock shows on the site but...
3
by: Jonathan | last post by:
I have taken up C++ programming again and need to write a socket client, so far I am able to create the connection to the socket. As I need a unix timestamp in char to put on a socket in a HTTP...
0
by: sloan | last post by:
Select Convert( int , MyTimeStampColumn ) as MyTimeStampINT from dbo.SomeTable Then use it as an int in your c# Use an alias so you keep it straight. (MyTimeStampINT is my alias)
4
by: Tim Kelley | last post by:
Is it possible to store a sql2000 timestamp field to a variable in C#. I am creating a dataset from a stored procedure and one of the fields is a timestamp field. I have created a variable of...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.