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 2000 Forums
 SQL Server Development (2000)
 DateTime Interval

Author  Topic 

dimitri24
Starting Member

8 Posts

Posted - 2003-02-19 : 16:15:50
I have a number of entries in database with a sertain date and time.
I need to retrieve all the data with a time between now and (now + 30 minutes).

help!

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-02-19 : 16:21:35
SELECT * FROM myTable
WHERE dateCol BETWEEN getdate() and DateAdd(minute, 30, getdate())

Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-02-19 : 16:23:23
From Right Now + 30 Minutes? Can you forsee future transactions? Do you Mean - 30 minutes?

Anyway, look in BOL For DateAdd function

For what you asked for, it would be:

WHERE date_col between GetDate() AND DateAdd(mi,30,GetDate())

Hope this helps

Brett

8-)

Go to Top of Page

dimitri24
Starting Member

8 Posts

Posted - 2003-02-19 : 16:25:41
quote:

SELECT * FROM myTable
WHERE dateCol BETWEEN getdate() and DateAdd(minute, 30, getdate())





THANKS

Go to Top of Page
   

- Advertisement -