前一天或后一天

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
Source Code

 

后一天:

 

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
Source Code

 

如果获取昨天或明天日期,传入今天日期进去即可:

 

posted @ 2019-05-15 09:21  Insus.NET  阅读(467)  评论(0编辑  收藏  举报