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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date range 1

Status
Not open for further replies.

xxing

Programmer
Feb 17, 2004
61
NZ
Hi I have to find if a date range is valid

Parameters
Start Date = 1 Sept 2008
End Date = 30 Sept 2008

Example 1 :
StartDate column value = 2 Sept 2008
EndDate column value = 10 September 2008
I want Example 1 to appear in the report

Example 2 :
StartDate Column value = 10 August 2008
EndDate Column value = 5 September 2008
I want example 2 to appear in the report as part of the range from StartDate to EndDate is with in the parameters range

Example 3 :
StartDate Column value = 5 August 2008
EndDate column value = 5 October 2008
I want example 3 to appear in the report as part of its range is with in the Start Date and End Date parameters range


If the range from StartDate to EndDate is not in the parameters range then don't show

How do I do this?. (All dates are datetime format)

Thank you
Mark
 
Hi,

This is an overlapping date problem. Try...

Code:
select * from [table] where 
(@start between [StartDate]and [EndDate]) or
(@end between [StartDate] and [EndDate]) or
([StartDate] between @start and @end) or
([EndDate] between @start and @end)

Ryan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top