All Forums Database
aarsh.dave 24 posts Joined 11/12
23 Jan 2014
Formatting CURRENT_TIMESTAMP

Hi All,
I want to select the current_timestamp in a specific format 'YYYYMMDDHH24MISS'.
Can you please let me know how I should go about it?

M.Saeed Khurram 544 posts Joined 09/12
23 Jan 2014
select CAST((current_timestamp(0) (format 'YYYYMMDDHHMISS')) AS VARCHAR(14))

 

Khurram

Raja_KT 1246 posts Joined 07/09
24 Jan 2014

If you are particular about current_timestamp, you can think of :
select cast((current_timestamp(FORMAT 'YYYYMMDD')) as char(8))||cast((current_timestamp(FORMAT 'HHMISS')) as char(6))

Raja K Thaw
My wiki: http://en.wikipedia.org/wiki/User:Kt_raj1
Street Children suffer not by their fault. We can help them if we want.

aarsh.dave 24 posts Joined 11/12
27 Jan 2014

Thanks Khurram and Raja. It helped :)

Adeel Chaudhry 773 posts Joined 04/08
01 Feb 2014

You dont need to cast to varchar/char if you are connected via CLI .... it is required on ODBC connectivity.

-- If you are stuck at something .... consider it an opportunity to think anew.

M.Saeed Khurram 544 posts Joined 09/12
02 Feb 2014

Adeel,
 
I have a question, do we need to cast it to varchar while inserting through ODBC ? Or it is only required for display purpose?
 

Khurram

Adeel Chaudhry 773 posts Joined 04/08
03 Feb 2014

Its only for display purpose. You can insert it like '2014-01-01 00:00:00' just fine .... and this is the default format that is suggested to be used with TD.

-- If you are stuck at something .... consider it an opportunity to think anew.

Hustler 9 posts Joined 12/15
14 Jul 2016

how to find different timezone from one time zone?

Thanks,
Komal

You must sign in to leave a comment.