473,883 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date Falls Within a Range

4 New Member
I have three fields in a Union Access Query (ID, Begin_Date, End_Date). I want to modify the query to include a parameter date to be entered by the user and produce a result if the parameter date falls within the range of Begin_Date to End_Date. Any ideas?
Sep 20 '07 #1
13 4503
NeoPa
32,584 Recognized Expert Moderator MVP
If you post your current SQL for the query we not only get a bit of context within which to understand the request, but you also may end up with an answer more tailored to your needs.
Sep 20 '07 #2
citizenprice
4 New Member
Sorry. Must be the Newbie in me. Here is the union query code:
Expand|Select|Wrap|Line Numbers
  1. SELECT [CLIENT_ID], [BEGIN_DATE], [END_DATE] FROM Client_Count_Current_Placement
  2. UNION SELECT [CLIENT_ID], [BEGIN_DATE], [END_DATE] FROM Client_Count_Historical_Placement;
Now I want to have a user input a parameter date, and if this parameter date falls within the range of BEGIN_DATE to END_DATE, only those records would show. This would all be done within a query.

Thanks for any help and sorry for the growing pains.
Sep 20 '07 #3
mlcampeau
296 Recognized Expert Contributor
Sorry. Must be the Newbie in me. Here is the union query code:

SELECT [CLIENT_ID], [BEGIN_DATE], [END_DATE] FROM Client_Count_Cu rrent_Placement
UNION SELECT [CLIENT_ID], [BEGIN_DATE], [END_DATE] FROM Client_Count_Hi storical_Placem ent;

Now I want to have a user input a parameter date, and if this parameter date falls within the range of BEGIN_DATE to END_DATE, only those records would show. This would all be done within a query.

Thanks for any help and sorry for the growing pains.
I have very little experience with union queries but this should work ...NeoPa, correct me if I'm wrong.
Try this:

Expand|Select|Wrap|Line Numbers
  1. SELECT [CLIENT_ID], [BEGIN_DATE], [END_DATE] 
  2. FROM Client_Count_Current_Placement
  3. WHERE [Begin_Date]>=CDate([Enter the beginning date]) AND [End_Date]<=CDate([Enter the ending date])
  4. UNION 
  5. SELECT [CLIENT_ID], [BEGIN_DATE], [END_DATE] 
  6. FROM Client_Count_Historical_Placement
  7. WHERE [Begin_Date]>=CDate([Enter the beginning date]) AND [End_Date]<=CDate([Enter the ending date]);
Sep 20 '07 #4
NeoPa
32,584 Recognized Expert Moderator MVP
I have very little experience with union queries but this should work ...NeoPa, correct me if I'm wrong.
Of course Michelle ;)
I want to check up on where the WHERE clause comes for a UNION query so will be back shortly, but the OP is looking for a single date parameter which must fall between his two dates rather than a date range. I will be using the Between [A] And [b] construct for this but let me check the details in the help first. BRB.

PS. Don't be put off by this M. You were logically on the right lines and you were also very quick.
Sep 20 '07 #5
mlcampeau
296 Recognized Expert Contributor
Of course Michelle ;)
I want to check up on where the WHERE clause comes for a UNION query so will be back shortly, but the OP is looking for a single date parameter which must fall between his two dates rather than a date range. I will be using the Between [A] And [b] construct for this but let me check the details in the help first. BRB.

PS. Don't be put off by this M. You were logically on the right lines and you were also very quick.
ahh..it helps if I read the Ops question properly!
Sep 20 '07 #6
NeoPa
32,584 Recognized Expert Moderator MVP
It turns out that the WHERE clause is found WITHIN each SELECT statement so must be duplicated for both tables.
Expand|Select|Wrap|Line Numbers
  1. SELECT [CLIENT_ID], [BEGIN_DATE], [END_DATE] FROM Client_Count_Current_Placement
  2. WHERE [Please enter Date] Between [BEGIN_DATE] And [END_DATE]
  3. UNION SELECT [CLIENT_ID], [BEGIN_DATE], [END_DATE] FROM Client_Count_Historical_Placement
  4. WHERE [Please enter Date] Between [BEGIN_DATE] And [END_DATE]
Sep 20 '07 #7
NeoPa
32,584 Recognized Expert Moderator MVP
If it is possible for the same [CLIENT_ID] to be in both tables then I suggest you use the ALL predicate of the UNION clause. This will ensure that all entries are returned. Otherwise (full) duplicates will be stripped automatically.

Michelle, don't worry about it. We're all learning lessons as we go.
Sep 20 '07 #8
mlcampeau
296 Recognized Expert Contributor
If it is possible for the same [CLIENT_ID] to be in both tables then I suggest you use the ALL predicate of the UNION clause. This will ensure that all entries are returned. Otherwise (full) duplicates will be stripped automatically.

Michelle, don't worry about it. We're all learning lessons as we go.
I was actually about to post the same solution you just did, but saw you beat me to it! I'm not worried at all. I'm so new to Access and I know I have lots to learn!
Sep 20 '07 #9
NeoPa
32,584 Recognized Expert Moderator MVP
I should have made that clearer. That last comment was a direct response to your previous comment.
ahh..it helps if I read the Ops question properly!
I wasn't commenting on your SQL offering as there was nothing to worry about there in the first place :)
Sep 20 '07 #10

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

Similar topics

2
5235
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
4
2502
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
6
3244
by: alexanderpope11 | last post by:
Hello, how do I write this SQL: I would like to check the Main table for invalid rows. An invalid row is: any row where the Start_date to stop_date range overlaps an invalid date in the Code table. For example, Row#2 is invalid because the Start_date-Stop_Date range overlaps 2 days in the code table where the code AA was not valid (12/30/2000 - 12/31/2000) Main Table
18
38261
by: dfetrow410 | last post by:
Anyone have some code that will do this? Dave
1
2270
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
1541
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
2562
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...
2
7512
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. In my VB.NET application I need to identify whether or not a user-input date falls in between certain date ranges. For example, If I know my date range is 4/1/2008 - 5/1/2008, and a user inputs 4/3/2008, I would need a boolean TRUE indicating that the input date falls between date ranges. I know I could do greater than/less than comparisons, but I want to check if there's a simpler way to accomplish this. Thank you.
13
2150
WyvsEyeView
by: WyvsEyeView | last post by:
I have a datasheet subform on which users select a topic from a combo box populated by a query, qryListTopicsCbo. This query limits the list to only those topics edited within the last n days (where n is supplied by a field on another form). The problem I am having is that if a user has selected a topic in the past but its last edit date now falls outside of the n range, that topic no longer appears on the form. Obviously, I want topics already...
0
9940
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
11141
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...
0
10742
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10847
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
7126
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
5797
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
5991
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4220
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3232
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.