473,769 Members | 6,831 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date Criteria that falls within a date range

4 New Member
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 4362
Rabbit
12,516 Recognized Expert Moderator MVP
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
lvjan777
4 New Member
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.P rj_Name, tblOSSProject.p rj_Description, tblOSSProject.p rjXPRMsnDate, tblOSSProject.p rjEndDate
FROM tblOSSProject
WHERE (((tblOSSProjec t.prjXPRMsnDate )<=[forms]![frmselectdates].[txtstopdate]) AND ((tblOSSProject .prjEndDate)>=[forms]![frmselectdates].[txtstartdate]));
Oct 25 '07 #3
Rabbit
12,516 Recognized Expert Moderator MVP
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
lvjan777
4 New Member
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 Recognized Expert Moderator MVP
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
5219
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 appreciated. TIA
5
14896
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 geographical region. I have written a query which prompts the user for the start and end dates. It also filters for entries which pertain to the particular geographical region. I'm not sure where to go from here.
4
2493
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 to record the record's status. Sample data: *tblTest* Model Parts CDate CStatus RDate RStatus 616 $359.79 03-Nov-03 C
1
1762
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 the correct date. Now I want my criteria on that column to allow me to return only date in a given to from period of my choosing. I try the between_and functions but nothing is returned. I'm guessing it's because the column is still a calculation...
18
38246
by: dfetrow410 | last post by:
Anyone have some code that will do this? Dave
1
3286
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 in the query regarding the date. Example: I have 3 new staff member in month August. The last time user wanted output from the staff table was for month July. So the criteria for the Appointment Date in my query was set "between #01/07/2006# and...
1
2266
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 within that range. Thank you, -Dean Miller
1
1540
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 #2/1/2007# And #2/28/2007#) - but found this excluded courses beginning on the first and last date of my date range. I changed the code to this - (( I.STARTDATE) Between #1/31/2007# And #3/1/2007#) and retreived my missing records, but found I was pulling in...
10
2558
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 ( http://www.dotnetspider.com/kb/Article1252.aspx) that gives examples using on the DateAdd() and DateDiff() functions, but it seems that not all of the examples work as described.... and of course, the last example in the article is very close to what I need yet does not work (I...
0
10223
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10000
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3968
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.