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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 getdate and between

Author  Topic 

kenlok
Starting Member

16 Posts

Posted - 2009-11-04 : 01:44:19
Hi,

How can I write a query to check the CreateDateTime which is from now with-in 1 hours?

Thanks

(Assumet now is 29/7/2008 11:56)

Before
-------------------------------------------------
Source Subject CreateDateTime CompleteDateTime
A MODIFY 29/7/2008 10:14 NULL
A MODIFY 29/7/2008 10:22 NULL
A MODIFY 29/7/2008 11:24 NULL
A MODIFY 29/7/2008 11:54 NULL




After
------------------------------------------------
Source Subject CreateDateTime CompleteDateTime
A MODIFY 29/7/2008 11:24 NULL
A MODIFY 29/7/2008 11:54 NULL

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-11-04 : 03:16:09
where date_column between dateadd(hour,-1,getdate()) and getdate()


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-04 : 03:17:38

where date_col>=dateadd(hour,-1,getdate())

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-11-04 : 03:19:11
quote:
Originally posted by madhivanan


where date_col>=dateadd(hour,-1,getdate())

Madhivanan

Failing to plan is Planning to fail


madhi - that's too simple


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-11-04 : 03:39:18
quote:
Originally posted by webfred

quote:
Originally posted by madhivanan


where date_col>=dateadd(hour,-1,getdate())

Madhivanan

Failing to plan is Planning to fail


madhi - that's too simple


No, you're never too old to Yak'n'Roll if you're too young to die.


People always want to have simple solutions

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

kenlok
Starting Member

16 Posts

Posted - 2009-11-04 : 05:39:32
Woo~~~~~

thanks so much!!
Go to Top of Page
   

- Advertisement -