I can extract the month and day by using Day(Date())
, Month(Date())
. I can\'t extract hours, with HOUR(Date())
. I get the following er
I can't extract hours, with HOUR(Date())
There is a way to call HOUR
(I would not recommend to use it though because there is DATEPART
function) using ODBC Scalar Functions:
SELECT {fn HOUR(GETDATE())} AS hour
LiveDemo
Try this one too:
SELECT CONVERT(CHAR(8),GETDATE(),108)
Use datepart.
E.g.:
datepart(hh, date)
you must use datepart()
like
datepart(hour , getdate())
select convert(time,GETDATE())
select case when [am or _pm] ='PM' and datepart(HOUR,time_received)<>12
then dateadd(hour,12,time_received)
else time_received
END
from table
works