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 error.
'HOUR' is not a recognized built-in function name.
How can I extract hours?
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 error.
'HOUR' is not a recognized built-in function name.
How can I extract hours?
To include AM / PM - use the below:
SELECT
concat(case when datepart(hour,getdate()) % 12 = 0 then 12
else datepart(hour,getdate()) % 12 end,
case when datepart(hour,getdate()) < 12 then ' AM'
else ' PM' end
)