Extracting hours from a DateTime (SQL Server 2005)

后端 未结 11 538
野趣味
野趣味 2020-12-01 03:21

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

11条回答
  •  北海茫月
    2020-12-01 03:53

    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

提交回复
热议问题