Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

MS SQL Server all records after current date 8AM Local Time

My SQL Server time is EST + 4

How would I select * from Individuals where DateAdded >= (8am local time)
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

Is DateAdded a column? Do you have a column with the date record was inserted?
ASKER CERTIFIED SOLUTION
Avatar of Vitor Montalvão
Vitor Montalvão
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Depends a bit on what you mean local time and comparing to what other time zones are in play....

If local to your server, then you can calculate : select dateadd(hour,8,datediff(day,0,getdate()))  to get 8:00am today.

Select * from Individuals where DateAdded >= dateadd(hour,8,datediff(day,0,getdate()))

Open in new window


Or just use datepart(hour,DateAdded) >= 8 (regardless of day)

But if there is some international date times to consider, then you might need to go to UTC times and in 2008 DATETIMEOFFSET was introduced which could prove interesting - but it all depends on whatever "local" really means :)
Avatar of Larry Brister

ASKER

Thanks
@Vitor,

That is as close to a blind link as I ever want to see....

The very least you could have done is to show Larry how it can be used to get > 8:00am local time.