December 23, 2008 at 4:59 am
I was wondering if the datepart function could produce the format in
yyyymmddhhnnss.
Aslo, if not since this is expected to be a string, can convert() be made useful?
December 23, 2008 at 5:11 am
i tried this.
select convert(varchar,getdate(),112)+ replace (convert(varchar,getdate(),108),':','')
December 23, 2008 at 5:37 am
Thanks...
well, i tried to find out all the styles
by using below code:
declare @style int
set @style=1
while @style <= 500
begin
print CONVERT(CHAR(100),GETDATE(),@style)
set @style=@style + 1
end
however i did not get 20081223 as output for any of the style though 112 is included in the range.
Could you please let me know why?
December 23, 2008 at 5:44 am
nabajyoti.b (12/23/2008)
Thanks...well, i tried to find out all the styles
by using below code:
declare @style int
set @style=1
while @style <= 500
begin
print CONVERT(CHAR(100),GETDATE(),@style)
set @style=@style + 1
end
however i did not get 20081223 as output for any of the style though 112 is included in the range.
Could you please let me know why?
Refer Books Online for CONVERT to see all possible styles.
OR
In a Query Window type "CONVERT" and double click it to select.
Press "Shift+F1" and there you will see all the possible options for style
Thanks,
Santhosh
December 23, 2008 at 6:09 am
nabajyoti.b (12/23/2008)
however i did not get 20081223 as output for any of the style though 112 is included in the range.Could you please let me know why?
Because not all the styles between 1 and 500 exist. As soon as you try to use CONVERT with non-existing style, you get error and further execution is aborted. In your case, it crashes on style 15.
As was mentioned before, refer to the manual (Books Online) for all valid styles.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply