473,395 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Date Criteria that falls within a date range

Access 2003 Windows XP Professional

I'm trying to open a report that displays all the records that are active during the user selected start and stop dates. I’m having trouble with the syntax since there are two input dates and two database dates to compare.

If they select 1 Apr 04 – 30 Apr 04 I want to see record 1.
If they select 1 May 04 – 30 May 04 I want to see record 1 and 2

Record 1
Start Date 12 Apr 04
Stop Date 30 Sep 07

Record 2
Start Date 15 May 04
End Date 15 July 05

Here's what I tried to use. It works if you select 1 Apr 04 - 30 Apr 04 but doesn't work if you select 1 May 04 - 30 May 04

Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenReport stDocName, acViewPreview, , (startdate & " between " & Me.txtStartDate & " and " & Me.txtStopDate & " Or " & stopdate & " between " & Me.txtStartDate & " and " & Me.txtStopDate & " Or " & Me.txtStartDate & " between " & startdate & " and " & stopdate & " Or " & Me.txtStopDate & " between " & startdate & " and " & stopdate)
Oct 18 '07 #1
5 4345
Rabbit
12,516 Expert Mod 8TB
Assuming you have no nulls:
StartDate <= txtEndDate AND EndDate >= txtStartDate

Also, you might have to delimit your dates using pound signs.
Oct 18 '07 #2
Assuming you have no nulls:
StartDate <= txtEndDate AND EndDate >= txtStartDate

Also, you might have to delimit your dates using pound signs.
Thanks for your help. I'm still having problems with this though. It works for some dates, but not others. Here is the sql. I don't know where to delimit the dates with pound signs. I tried cdate on the date coming from the form but that didn't help.

My first record has a start date of 4/12/04 and an end date of 8/30/07. I input 4/1/04 and 4/30/04 as the date ranges, but it doesn't return the first record. Both criteria are met so it should return the record.
4/12/04 <= 4/30/04 and 9/30/07 >= 4/1/04


SELECT tblOSSProject.Prj_Name, tblOSSProject.prj_Description, tblOSSProject.prjXPRMsnDate, tblOSSProject.prjEndDate
FROM tblOSSProject
WHERE (((tblOSSProject.prjXPRMsnDate)<=[forms]![frmselectdates].[txtstopdate]) AND ((tblOSSProject.prjEndDate)>=[forms]![frmselectdates].[txtstartdate]));
Oct 25 '07 #3
Rabbit
12,516 Expert Mod 8TB
Hmm, the SQL looks fine. I would try checking the data types of the 2 fields in the table and the two text boxes in the form and make sure they're of date data type.
Oct 25 '07 #4
Hmm, the SQL looks fine. I would try checking the data types of the 2 fields in the table and the two text boxes in the form and make sure they're of date data type.
I hard coded the dates in the query and it works fine with # around the date. I'm passing in the dates from a form with two unbound text boxes. I was testing the query in the QBE and didn't get the results I expected. When I pass in the dates from the form, it works. Thanks for your help.
Oct 25 '07 #5
Rabbit
12,516 Expert Mod 8TB
I hard coded the dates in the query and it works fine with # around the date. I'm passing in the dates from a form with two unbound text boxes. I was testing the query in the QBE and didn't get the results I expected. When I pass in the dates from the form, it works. Thanks for your help.
Not a problem, good luck.
Oct 25 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
5
by: BlackFireNova | last post by:
I need to write a report in which one part shows a count of how many total records fall within the working days (Monday - Friday) inside of a (prompted) given date range, in a particular...
4
by: Stewart Allen | last post by:
I'm trying to filter a table that has 2 date fields, the first date will always have a value but the second will only occasionally has a value. Each date field also has a corresponding text field...
1
by: John Feeley | last post by:
am tring to add a number of years to a dob. im doing this by adding my date+years*365.26 I get a string of numbers. I then convert the number in the next column to actual date again. I'm getting...
18
by: dfetrow410 | last post by:
Anyone have some code that will do this? Dave
1
by: isetea | last post by:
Hi, I want to create a from where user can select from a date range / type in a date range to get only data from an underlying query within this range. This should overwrite the existing criteria...
1
by: DeanMiller | last post by:
I was wondering if there is an easy way to check if a date falls in a given selection range. I have the selection range already made and I want to be able to take a given date and see if it falls...
1
by: heckstein | last post by:
I am running a query in Access 2003 to pull training courses with a start date that falls within a specified date span such 2/1/07 to 2/28/07. I was using this code - (( I.STARTDATE) Between...
10
by: Andrew | last post by:
Having trouble with some date computations. I need to get the date of a specific day within a month - the 1st Thursday or the 2nd Monday, etc. I found an article (...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.