473,698 Members | 2,344 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 4480
NeoPa
32,569 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,569 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,569 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,569 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,569 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
5214
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
2489
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
3231
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
38236
by: dfetrow410 | last post by:
Anyone have some code that will do this? Dave
1
2261
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
1537
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
2548
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
7496
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
2127
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
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8871
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
6528
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
5861
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
4371
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
4622
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
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
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
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.