Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Time in Hourly

Author  Topic 

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2013-09-10 : 05:03:41
I need to convert to dateadd Hour 8 to get the current time. Will like to schedule a job to run every hour.

How can I apply it in where condition?

select dateadd(hour,8,GETDATE())

0000-0100
0100-0200
0200-0300
'
'
'
'

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-09-10 : 06:18:12
1) Create one table with Time slots as follows:
StartTime EndTime
0000 0100
0100 0200
0200 0300

While retrieving data use as follows:
SELECT * FROM SourceTable
WHERE TimeColumn BETWEEN StartTime AND EndTime


--
Chandu
Go to Top of Page
   

- Advertisement -