首页 > 代码库 > sqlserver日期操作

sqlserver日期操作

 

declare @aa datetime
declare @bb datetime

SET @aa=GETDATE()
print @aa


set @bb=CONVERT(datetime,‘2017 04 29 15:00:00‘)
print @bb

print datediff(day, @aa,@bb)
print datediff(hour, @aa,@bb)
print datediff(minute , @aa,@bb)
print datediff(second , @aa,@bb)

 

 

==============输出内容====================

 

04 29 2017 2:58PM
04 29 2017 3:00PM
0
1
2
71

sqlserver日期操作