我如何像这样截断 sql server 2008 中的日期:
How do i trunc the date in sql server 2008 like this :
我有 2012-01-02 12:04:11.443
我只想选择 2012-01-02 12:00:00.000
和 2012-01-02 12:04:00.000
(小时和分钟级别)
I have 2012-01-02 12:04:11.443
and I want only to select 2012-01-02 12:00:00.000
and 2012-01-02 12:04:00.000
(hour and minute level)
declare @D as datetime = '2012-01-02T12:04:11.443'
select dateadd(hour, datediff(hour, 0, @D), 0)
select dateadd(minute, datediff(minute, 0, @D), 0)
这篇关于将日期截断为仅小时/分钟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!