Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / March 2006

Tip: Looking for answers? Try searching our database.

Convert TimeStamp

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris - 28 Feb 2006 15:55 GMT
Banging my head on this and it is probably  simple....

What is the cleanest way to get today's timestamp in a character string
of 14 without seperators YYYYMMDDHHMMSS?

Ie : 2006-02-28-10.53.37.230256
as
20060228105337

I know I can use SUBSTR but seems like a cludge...

Chris
Brian Tkatch - 28 Feb 2006 16:50 GMT
Instead of SUBSTR you could use YEAR(), MONTH(), etc...

Or: REPLACE(TRANSLATE(CHAR(CURRENT TIMESTAMP), '', '.-'), ' ', '')

B.
Chris - 28 Feb 2006 18:33 GMT
Hmm, didn't work for me. Errored on TRANSLATE. Maybe I messed up the
quotes. However, you did give me an Idea. Hence, this works:

Substr(
     REPLACE(REPLACE( CHAR(CURRENT TIMESTAMP), '-', ''), '.','')
,1,14)

Chris
Ian - 09 Mar 2006 00:48 GMT
> Banging my head on this and it is probably  simple....
>
[quoted text clipped - 4 lines]
> as
> 20060228105337

cast(bigint(your_timestamp) as char(14))
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.