Larry Brister
asked on
SQL Server DatePart HOUR
Does my select below differentiate on the 24 hour clock?
DECLARE @Hours INT
SET @Hours = DATEPART(HOUR, GETDATE())
DECLARE @Hours INT
SET @Hours = DATEPART(HOUR, GETDATE())
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Explain for us at Barney-level what you are trying to pull off, as I'm not getting what you are asking us.
ASKER
Well...
I am getting usage stats from an api in my own .Net app
Those stats come in on the same task that runs every 10 minutes for other "methods"
I want to store the usage stats every two hours instead of every 10 minutes.
So... without touching the .Net application that ALREADY is inserting the data
I want to modify the stored procedure to do it only every 2 hours
I am getting usage stats from an api in my own .Net app
Those stats come in on the same task that runs every 10 minutes for other "methods"
I want to store the usage stats every two hours instead of every 10 minutes.
So... without touching the .Net application that ALREADY is inserting the data
I want to modify the stored procedure to do it only every 2 hours
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Perfect... thanks
ASKER
Maybe the every two hours part is clunky?
DECLARE @LastEntry DATETIME
DECLARE @Hours INT
SET @Hours = DATEPART(HOUR, GETDATE())
SET @LastEntry = ( SELECT MAX(ISNULL(DateAdded, GETDATE()))
FROM dbo.SendGridAllocations
)
IF (@Hours - DATEPART(HOUR, @LastEntry) > 0 AND @Hours IN (2,4,6,8,10,12,14,16,18,20
BEGIN
Open in new window