473,569 Members | 2,762 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

BETWEEN and AND statements

I have a query with this Between statement as the criteria:
"Between [Enter 1st Qtr - (eg March 2003)] And [End Qtr - (eg June 2004)]"
If I key in June 2002 as the first quarter date and June 2004 as the second
quarter date I get data for June 2002 upto March 2004 not June 2004. How can
I change the Between statement to include June 2004 if I enter June 2004?
TIA
Tony Williams
Nov 13 '05 #1
6 4267
"Tony Williams" <tw@tcpinvalid. com> wrote in message
news:cn******** **@sparta.btint ernet.com...
I have a query with this Between statement as the criteria:
"Between [Enter 1st Qtr - (eg March 2003)] And [End Qtr - (eg June 2004)]"
If I key in June 2002 as the first quarter date and June 2004 as the second
quarter date I get data for June 2002 upto March 2004 not June 2004. How can
I change the Between statement to include June 2004 if I enter June 2004?


What kind of field is this criteria being applied to? The entry "March 2003" is
meaningless when applied to a Date field. If applied to a calculated field that
produces "mmmm yyyy" output from a Date field the resulting filter would be an
alphabetical one, not chronological.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #2
Sorry Rick I'm a little confused. I have the control as a date field with
the format mmmm yyyy and it seems to work as far other criteria are
concerned eg the following:
Between DateSerial(Year ([Enter 1st Qtr End Date]),1,1) And [Enter 1st Qtr
End Date] Or Between DateSerial(Year ([Enter 2nd Qtr End Date]),1,1) And
[Enter 2nd Qtr End Date]

Is that purely coincidence or am I missing something?
Thanks
Tony
PS Bit of an amateur so forgive the naivety!

"Rick Brandt" <ri*********@ho tmail.com> wrote in message
news:30******** *****@uni-berlin.de...
"Tony Williams" <tw@tcpinvalid. com> wrote in message
news:cn******** **@sparta.btint ernet.com...
I have a query with this Between statement as the criteria:
"Between [Enter 1st Qtr - (eg March 2003)] And [End Qtr - (eg June 2004)]" If I key in June 2002 as the first quarter date and June 2004 as the second quarter date I get data for June 2002 upto March 2004 not June 2004. How can I change the Between statement to include June 2004 if I enter June
2004?
What kind of field is this criteria being applied to? The entry "March 2003" is meaningless when applied to a Date field. If applied to a calculated field that produces "mmmm yyyy" output from a Date field the resulting filter would be an alphabetical one, not chronological.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com

Nov 13 '05 #3
"Tony Williams" <tw@tcpinvalid. com> wrote in message
news:cn******** **@titan.btinte rnet.com...
Sorry Rick I'm a little confused. I have the control as a date field with
the format mmmm yyyy and it seems to work as far other criteria are
concerned eg the following:
Between DateSerial(Year ([Enter 1st Qtr End Date]),1,1) And [Enter 1st Qtr
End Date] Or Between DateSerial(Year ([Enter 2nd Qtr End Date]),1,1) And
[Enter 2nd Qtr End Date]

Is that purely coincidence or am I missing something?
Thanks


Well this new code example you gave is using DateSerial() to produce an actual
Date value from the parameter being entered.

Someone entering "March 2003" into a parameter provided by your first code...

"Between [Enter 1st Qtr - (eg March 2003)] And [End Qtr - (eg June2004)]"

....that doesn't have DateSerial around it is just going to be treated as the
text string "March 2003".
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #4
So should I change the parameter to use DateSerial()?So it would become
Between DateSerial(Year ([Enter 1st Qtr - (eg March 2003)] ,1,1) And
DateSerial(Year[End Qtr - (eg June2004)] ,1,1)
Sorry to be so slow on the uptake here, I would really like to understand
the difference
Thanks
Tony
"Rick Brandt" <ri*********@ho tmail.com> wrote in message
news:30******** *****@uni-berlin.de...
"Tony Williams" <tw@tcpinvalid. com> wrote in message
news:cn******** **@titan.btinte rnet.com...
Sorry Rick I'm a little confused. I have the control as a date field with the format mmmm yyyy and it seems to work as far other criteria are
concerned eg the following:
Between DateSerial(Year ([Enter 1st Qtr End Date]),1,1) And [Enter 1st Qtr End Date] Or Between DateSerial(Year ([Enter 2nd Qtr End Date]),1,1) And
[Enter 2nd Qtr End Date]

Is that purely coincidence or am I missing something?
Thanks
Well this new code example you gave is using DateSerial() to produce an

actual Date value from the parameter being entered.

Someone entering "March 2003" into a parameter provided by your first code...
"Between [Enter 1st Qtr - (eg March 2003)] And [End Qtr - (eg June2004)]"

...that doesn't have DateSerial around it is just going to be treated as the text string "March 2003".
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com

Nov 13 '05 #5
Ive tried this
Between DateSerial(Year ([Enter 1st Qtr - eg March 2003]),1,1) And [End Qtr -
eg June2004]
and still get the same problem the query doesn't return data for June 2004
Tony
"Rick Brandt" <ri*********@ho tmail.com> wrote in message
news:30******** *****@uni-berlin.de...
"Tony Williams" <tw@tcpinvalid. com> wrote in message
news:cn******** **@titan.btinte rnet.com...
Sorry Rick I'm a little confused. I have the control as a date field with the format mmmm yyyy and it seems to work as far other criteria are
concerned eg the following:
Between DateSerial(Year ([Enter 1st Qtr End Date]),1,1) And [Enter 1st Qtr End Date] Or Between DateSerial(Year ([Enter 2nd Qtr End Date]),1,1) And
[Enter 2nd Qtr End Date]

Is that purely coincidence or am I missing something?
Thanks
Well this new code example you gave is using DateSerial() to produce an

actual Date value from the parameter being entered.

Someone entering "March 2003" into a parameter provided by your first code...
"Between [Enter 1st Qtr - (eg March 2003)] And [End Qtr - (eg June2004)]"

...that doesn't have DateSerial around it is just going to be treated as the text string "March 2003".
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com

Nov 13 '05 #6
"Tony Williams" <tw@tcpinvalid. com> wrote in message
news:cn******** **@hercules.bti nternet.com...
So should I change the parameter to use DateSerial()?So it would become
Between DateSerial(Year ([Enter 1st Qtr - (eg March 2003)] ,1,1) And
DateSerial(Year[End Qtr - (eg June2004)] ,1,1)
Sorry to be so slow on the uptake here, I would really like to understand
the difference


Your table has Date fields and will only understand comparisons to other date
values. The query...

SELECT * FROM SomeTable
WHERE DateField BETWEEN "March 2004" AND "June 2004"

.... will not work because "March 2004" is NOT a date it is a String. A person
can see that it represents a month and year but Access cannot.

You need a Query that will evaluate to...

SELECT * FROM SomeTable
WHERE DateField BETWEEN #03/01/2004# AND #06/30/2004#

Then you are comparing Dates to Dates. If you want your user to only have to
provide the month and year then your expression has to take those entries and
STILL end up with something that Access will know is a Date.

I prefer DateSerial, but you would have to feed it three separate arguments The
year and month would have to be provided with separate parameters and they would
all have to be numbers (you couldn't use "March" for example. CDate() can take
a string and convert it to a date and if it's not provided it will assume 1 for
the day.

SELECT * FROM SomeTable
WHERE DateValue
BETWEEN CDate([Enter 1st Qtr - (eg March 2003)])
AND CDate([End Qtr - (eg June 2003)])

However; the above will evaluate to...

SELECT * FROM SomeTable
WHERE DateField BETWEEN #03/01/2004# AND #06/01/2004#

Since June 1st is what is evaluated you will not actually get any records for
June unless they occur on June 1st at midnight. So you have to add an extra
month to the ending value.

SELECT * FROM SomeTable
WHERE DateValue
BETWEEN CDate([Enter 1st Qtr - (eg March 2003)])
AND DateAdd("m", 1, CDate([End Qtr - (eg June 2003)]))

You would really be better off dropping the self prompting parameter query and
feeding the criteria from a form. Self-prompting parameter queries are only
appropriate in the simplest of cases and are almost never used in a production
quality application.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2417
by: lkrubner | last post by:
Suppose I make a call to MySql and zero rows come back. How do I tell the difference between zero rows and failure?
11
1313
by: ATSkyWalker | last post by:
What's the difference between these 2 statements? If you have a String s="12345" s = "54321" But s = "5432"
2
2237
by: uli2003wien | last post by:
Dear group, we are dealing with some very specific problems with ODBC, where a connection from SQL-Server to Mysql works with ODBC-driver 3.51.10.00 and does NOT work with ODBC-driver 3.51.11.00. Maybe someone experiences similar problems or even has a solution ? Some feedback (to the group) would be highly appreciated. We use a...
2
16321
by: amos_s12 | last post by:
Hello everybody Is there a possibility to make a delay between two sql statements, namely one sql statement is performed, then there is a delay of some seconds and then rhe next statement is performed. In sybase database, there is a possibility to do such thing by using the statement waitfor delay 'hh:mm:dd' for example: while(...)
27
3163
by: hokieghal99 | last post by:
What is the difference between these two statements? Are there any major differences? const char filename = "ips_c.txt"; char filename = "ips_c.txt"; Thanks!!!
3
8429
by: kai | last post by:
Hi, All What is the the difference between If and #If? I read some VB.NET books, sometimes I see #If, but cannot tell why. Please help. Thanks Kai
6
8413
by: nikhilbhavsar | last post by:
Hi Friends , I want to know the exact difference between collection ID and qualifier. I also want to know in detail : When we perform BIND operation on a stored procedure, what we are actually trying to do ? Why Bind operation is performed ?? Can anyone please tell me bout complete Lifecycle of developing a Stored Prcedure ??
13
10683
by: Jim Armstrong | last post by:
Hi all - This problem has been driving me crazy, and I'm hoping the answer is something stupid I am neglecting to see.... The procedure posted below is part of an Access/SQL database I have developed. Basically, the user would input a beginning and ending date, and the query goes and pulls records that meet the following criteria: 1....
4
9457
by: arnuld | last post by:
i am unable to understand the difference between a "C++ expression" and a "C++ statement". this is what i get from C++ Primer: expression The smallest unit of computation. An expression consists of one or more operands and usually an operator. Expressions are evaluated to produce a result. For example, assuming i and j are ints, then i...
9
19037
by: Logan Lee | last post by:
Hi. What's the difference between while and do while?
0
7694
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...
0
7609
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...
0
7921
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. ...
1
7666
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...
0
6278
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
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...
1
2107
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
1
1208
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
936
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...

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.