有没有一种方法可以测试何时一小时是完美的,比如SQL中的1:00、2:00、3:00与1:15、2:15和3:15



我想在下午1:00时将列"Start"报告为1PM,或在下午1:15PM时将其报告为1:15PM。

[Start] = Case When Right(Convert(varchar,c.CourseStartTime), 5) = '00:00'
Then Format(Cast(c.CourseStartTime As Datetime), 'htt') 
Else Format(Cast(c.CourseStartTime As Datetime), 'h:mmtt')End,
[End] = Case When Right(Convert(varchar,c.CourseEndTime), 5) = '00:00'
Then Format(Cast(c.CourseEndTime As Datetime), 'htt') 
Else Format(Cast(c.CourseEndTime As Datetime), 'h:mmtt')End,

您的语法建议使用SQL Server。我认为replace()format()可以满足您的要求:

select replace(format(getdate(), 'h:mmtt'), ':00', '')

最新更新