How to convert DATEADD(HH,-12,GETDATE()) result to 'yyyymmddhh'?
Posted on 2009-04-23
I have Integer data type column name Dimdatetimeid in my table. It has date and time info like 2009042310, 2009042322 etc. Now I want to get some info 12 hrs back onwards.
So I try to write the query
Select * from table1 where dimdatetimeid >= DATEADD(HH,-12,GETDATE()) like that.
The problem is DATEADD(HH,-12,GETDATE()) will give 2009-04-22 23:20:46.400
But I want to convert it as 2009042223. Please let me know. Thanks.