Home >Database >Mysql Tutorial >sqlserver 每30分自动生成一次

sqlserver 每30分自动生成一次

WBOY
WBOYOriginal
2016-06-07 16:18:45959browse

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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn