February 8, 2002 at 9:25 am
Hi, all
Here is a q for U.
I want to convert GETDATE() to this format,YYYYMMDDHHMMSS
I tried this way but did not work..
Convert(char(14),GETDATE(),120)
Any Idea???
Thx in advance..
Jay
February 8, 2002 at 10:40 am
check out this evolution
select
Convert( char( 20),GETDATE(),120)
, replace( Convert( char( 20),GETDATE(),120), '-', '')
, replace( replace( Convert( char( 20),GETDATE(),120), '-', ''), ' ', '')
, replace( replace( replace( Convert( char( 20),GETDATE(),120), '-', ''), ' ', ''), ':', '')
Steve Jones
February 8, 2002 at 11:34 am
awesome...
Thx
Jay
quote:
check out this evolutionselect
Convert( char( 20),GETDATE(),120)
, replace( Convert( char( 20),GETDATE(),120), '-', '')
, replace( replace( Convert( char( 20),GETDATE(),120), '-', ''), ' ', '')
, replace( replace( replace( Convert( char( 20),GETDATE(),120), '-', ''), ' ', ''), ':', '')
Steve Jones
February 11, 2002 at 11:23 pm
I added some user defined functions for working with dates.
Check out:
http://www.sqlservercentral.com/scripts/scriptdetails.asp?scriptid=175
and
http://www.sqlservercentral.com/scripts/scriptdetails.asp?scriptid=174
February 12, 2002 at 4:56 am
This will do it a hair faster and with less conversions and function calls which saves on CPU cycles.
CONVERT(VARCHAR,GETDATE(),112) + REPLACE(CONVERT(VARCHAR,GETDATE(),108),':','')
February 12, 2002 at 7:07 am
Thx..
This works great as well...
Jay
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply