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
 date in hours

Author  Topic 

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2013-06-06 : 23:27:33
how can i get time which is more than 6 hours?

my date format as below:

16:25:00
17:10:00
19:15:00
20:20:00
21:25:00

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-06-06 : 23:31:22
what do you mean exactly ?

what is the expected result ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2013-06-06 : 23:40:16
select time, ... from tableA, i get result as below:
time
16:25:00
17:10:00
19:15:00
20:20:00
21:25:00

i would like to schedule a job to only get 6 hours ahead time.

select time from tableA where time > 6 ?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-06-06 : 23:59:36
[code]
where [[time] > convert(varchar(8), dateadd(hour, 6, getdate()), 108)
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2013-06-07 : 00:12:33
is not working..

when i run this

select convert(varchar(8), dateadd(hour, 6, getdate()))

it appear: Jun 7 2
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-06-07 : 00:20:27
missed the style. Edited.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2013-06-07 : 00:21:48
have you also consider the situation when cross over to midnight ?

How would you want to handle it ?


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -