How to parse the query to hours instead of days in usql

58 Views Asked by At

I need to update logic to add buffer to to do data for last 24 hours instead of 7 days

DECLARE @todo = @opinion== 0? DateTime.UtcNow.AddDays( - 7) : new DateTime(@opinion);

Tried this with offset but it didn't work for me.

DECLARE @todo = @opinion== 0? DateTime.UtcNow.AddDays(-7) : new DateTimeOffset(@opinion, DateTime.UtcNow.AddHours(-24));
1

There are 1 best solutions below

0
Iguanaware On BEST ANSWER

opinion is within the last 7 hours

DECLARE @opinion = DateTime.UtcNow.AddHours(-9);

SELECT ...
WHERE opinion >=  DateTime.UtcNow.AddHours(-7) AND opinion <= DateTime.UtcNow;

Missing details for a complete answer.