Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning only records between 2 dates

Status
Not open for further replies.
Sep 17, 2001
4
0
0
GB
Hi,

I'm new to SQL and would appreciate any help!

I have a table that has a field called 'startdate' and a field called 'enddate'. I only want to return the records if todays date falls between these two dates. What is the proper way of going about this?

Thanks
 
try this

select * from table where GETDATE() between startdate and enddate
 
Thanks! that works but I now realise that I need the records to show up if the startdate and enddate fields match todays date as well.
 
Between ([StartDate]) And DateAdd("d",1,[EndDate]) This will include todays date. When entering a date range the start date will give you that date at 12:00 AM but the end date will give you nothing after 12:00 AM. So you have to add 1 day in your coding to the end date.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top