sqlserver 每30分自动生成一次
DECLARE @BeginTime AS DATETIME DECLARE @EndTime AS DATETIME DECLARE @Hour AS INT DECLARE @Min AS INT SET @Min = DATEPART(Minute, GETDATE()) IF @Min 30 BEGIN SET @BeginTime = CONVERT(VARCHAR(10), GETDATE(), 120) + ' ' + CAST(DATEPART(Hour,
DECLARE @BeginTime AS DATETIME
DECLARE @EndTime AS DATETIME
DECLARE @Hour AS INT
DECLARE @Min AS INT
SET @Min = DATEPART(Minute, GETDATE())
IF @Min
BEGIN
SET @BeginTime = CONVERT(VARCHAR(10), GETDATE(), 120) + ' ' + CAST(DATEPART(Hour, GETDATE()) AS VARCHAR) + ':30'
SET @EndTime = CONVERT(VARCHAR(10), GETDATE(), 120) + ' ' + CAST(DATEPART(Hour, GETDATE()) AS VARCHAR) + ':00'
SET @BeginTime = DATEADD(Hour, -1, @BeginTime)
END
ELSE
BEGIN
SET @BeginTime = CONVERT(VARCHAR(10), GETDATE(), 120) + ' ' + CAST(DATEPART(Hour, GETDATE()) AS VARCHAR) + ':00'
SET @EndTime = CONVERT(VARCHAR(10), GETDATE(), 120) + ' ' + CAST(DATEPART(Hour, GETDATE()) AS VARCHAR) + ':30'
END
EXEC up_GenReport @BeginTime, @EndTime
,