Insus.NET把它們寫成自定義函數,再程式中直接套用即可。 前一天: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- -- Author: Insus.NET -- Create date: 2019-05-15 -- Update dat ...
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 GOSource 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 GOSource Code
如果獲取昨天或明天日期,傳入今天日期進去即可: