By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,557 Members | 1,068 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,557 IT Pros & Developers. It's quick & easy.

Convert TimeStamp

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
Instead of SUBSTR you could use YEAR(), MONTH(), etc...

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

B.

Feb 28 '06 #2

P: n/a
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

P: n/a
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.