Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
From 112 to DATEPART
Message
From
24/01/2011 20:58:57
 
 
To
All
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
From 112 to DATEPART
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01497298
Message ID:
01497298
Views:
89
I have this:
SELECT CONVERT(CHAR(8),Hit.AddDate,112)
It is good to return a 20110124 syntax. Now, I have another situation where I have pretty much the same query but I need to add two additional digits representing the hour. Basically, it goes like this:
SELECT CONVERT(CHAR(4),YEAR(Hit.AddDate))+REPLACE(STR(MONTH(Hit.AddDate),2),' ','0')+
 REPLACE(STR(DAY(Hit.AddDate),2),' ','0')+REPLACE(STR(DATEPART(HOUR,Hit.AddDate),2),' ','0')
What would be the replacement of 112 to obtain a syntax like 2011012412, which would represent the 12th hour for example.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Next
Reply
Map
View

Click here to load this message in the networking platform