首页 >数据库 >mysql教程 >sqlserver 每30分自动生成一次

sqlserver 每30分自动生成一次

WBOY
WBOY原创
2016-06-07 16:18:45961浏览

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

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn