March 20, 2009 at 6:18 am
how to display date in yyyyMMddhhmmss format
March 20, 2009 at 6:22 am
Hi
What do you mean with display?
If you want to select DATETIME values in specified format:
It is possible, but you should not do it. You should format your output format within the client.
If you want to format your output within the client:
Which programming language? Which data access library?
Greets
Flo
March 20, 2009 at 6:23 am
use convert function and you can do this. look for Convert options in SQL BOL , hope this helps 🙂
March 20, 2009 at 6:23 am
Use CONVERT with the correct style (probably 121 would do) and length, and then REPLACE delimiters if you don't want them in the result.
March 20, 2009 at 6:24 am
HI,
Try this..
SELECT CONVERT(VARCHAR(19), GETDATE(), 120) DATE
,REPLACE(REPLACE(REPLACE(CAST(CONVERT(VARCHAR(19), GETDATE(), 120) AS VARCHAR(20)),'-',''),':',''),' ','') FORMATDATE
Regards,
Ashok S
March 20, 2009 at 7:37 am
here's how i do it:
FormattedDate SQL
20090320-09:33:49:700 SELECT CONVERT(VARCHAR,@date,112) + '-' + CONVERT(VARCHAR,@date,114)
20090320-093349700 SELECT CONVERT(VARCHAR,@date,112) + '-' + REPLACE(CONVERT(VARCHAR,@date,114),':','')
20090320093349 SELECT CONVERT(VARCHAR,@date,112) + LEFT(REPLACE(CONVERT(VARCHAR,@date,114),':',''),6)
Lowell
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply