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.