Query between dates (1 Viewer)

eacollie

Registered User.
Local time
Yesterday, 23:10
Joined
May 14, 2011
Messages
159
I have a [StartDate] and[EndDate] and I want to select any records that fall between these two dates. If I select [StartDate] >= date1 and [EndDate] <= date2, I don't get the records that have a start date BEFORE the date1 but occurred during this date range.

How do I write the query for this?

Thank you!
 

Ranman256

Well-known member
Local time
Today, 02:10
Joined
Apr 9, 2015
Messages
4,337
If the dates are in text boxes on the form,

Select * from table where forms!myForm!txtDate1 >= [startDate] and forms!myForm!txtDate2 <= [endDate]
 

eacollie

Registered User.
Local time
Yesterday, 23:10
Joined
May 14, 2011
Messages
159
Thank you. That gives me anything starting after that date. I want to select anything happening BETWEEN those dates.

For example:
[StartDate] = 1/1/2018 and [End Date] = 1/6/2018

If I select anything starting 1/2/2018 I don't get the above included in the result.
 

eacollie

Registered User.
Local time
Yesterday, 23:10
Joined
May 14, 2011
Messages
159
Thank you jdraw! That's EXACTLY what I was looking for. (And thank you PBaldy). :D
 

jdraw

Super Moderator
Staff member
Local time
Today, 02:10
Joined
Jan 23, 2006
Messages
15,377
You're welcome - Paul Baldy and I are happy to help.
Good luck.
 

Users who are viewing this thread

Top Bottom