insus.net把它们写成自定义函数,再程序中直接套用即可。
前一天:
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_thedaybefore] ( @date datetime ) returns datetime as begin return dateadd(d,-1,@date) end go
后一天:
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_thedayafter] ( @date datetime ) returns datetime as begin return dateadd(d,1,@date) end go
如果获取昨天或明天日期,传入今天日期进去即可: