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

sqlserver 每30分自动生成一次

WBOY
Release: 2016-06-07 16:18:45
Original
957 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template