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
如果获取昨天或明天日期,传入今天日期进去即可: