以前写过一个方法,先去参考《t-sql判断是否为今天》
今天使用一个更加简单的方法来实现:
set ansi_nulls on go set quoted_identifier on go -- ============================================= -- author: insus.net -- create date: 2019-05-15 -- update date: 2019-05-15 -- description: 判断日期是不是今天 -- ============================================= create function [dbo].[svf_istoday] ( @date datetime ) returns bit as begin return case when datediff(dd,0,@date) = datediff(dd,0,current_timestamp) then 1 else 0 end end go
实例演示: