467,113 Members | 1,368 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

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

Convert TimeStamp

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

Feb 28 '06 #1
  • viewed: 11045
Share:
3 Replies
Instead of SUBSTR you could use YEAR(), MONTH(), etc...

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

B.

Feb 28 '06 #2
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

Feb 28 '06 #3
Ian
Chris wrote:
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


cast(bigint(your_timestamp) as char(14))
Mar 9 '06 #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
8 posts views Thread by Chris | last post: by
4 posts views Thread by Dean Slindee | last post: by
10 posts views Thread by satishrajana@gmail.com | last post: by
5 posts views Thread by whitsey | last post: by
4 posts views Thread by skulkrinbait@googlemail.com | last post: by
4 posts views Thread by Tim Kelley | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.