473,385 Members | 1,320 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,385 software developers and data experts.

date range

Hi,
I select from an Access table " where date >= '3/1/2004' and date
<='3/31/2004' ", but no record. Can you tell me how to make this
comparission?
Thanks
--
Andrew

Jul 19 '05 #1
12 1741
Andrew wrote:
Hi,
I select from an Access table " where date >= '3/1/2004' and date
<='3/31/2004' ", but no record. Can you tell me how to make this
comparission?
Thanks

Jet requires you to use # to delimit literal dates. You should use ISO date
format, like this:

where date >=#2004-03-01# and date <=#2004-03-31#
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #2
But Access datetime format only has 3/31/2004, how can I make it work?
Thanks

--
Andrew
"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Andrew wrote:
Hi,
I select from an Access table " where date >= '3/1/2004' and date
<='3/31/2004' ", but no record. Can you tell me how to make this
comparission?
Thanks

Jet requires you to use # to delimit literal dates. You should use ISO

date format, like this:

where date >=#2004-03-01# and date <=#2004-03-31#
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Jul 19 '05 #3
What I am going to do is to select the month or year from the date, for
example,
select * from table where thedate >=#2004-[var]-01# and thedate
<=#2004-[var]-31#
That means all the record in a month. Can you help? Thanks.

--
Andrew
"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Andrew wrote:
Hi,
I select from an Access table " where date >= '3/1/2004' and date
<='3/31/2004' ", but no record. Can you tell me how to make this
comparission?
Thanks

Jet requires you to use # to delimit literal dates. You should use ISO

date format, like this:

where date >=#2004-03-01# and date <=#2004-03-31#
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Jul 19 '05 #4
You are wrong. The ISO format I suggested will work fine. I have used it
myself.

Your error is in thinking that the database stores the dates in a particular
format. This is not true. If you read the online help, you will see that
Access stores date/time data as numbers of type Double. The whole number
portion represents the number of days since the seed date. The decimal
portion represents the time of day (.0 = midnight, .5 = noon)

Bob Barrows
Andrew wrote:
But Access datetime format only has 3/31/2004, how can I make it work?
Thanks
"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Andrew wrote:
Hi,
I select from an Access table " where date >= '3/1/2004' and date
<='3/31/2004' ", but no record. Can you tell me how to make this
comparission?
Thanks

Jet requires you to use # to delimit literal dates. You should use
ISO date format, like this:

where date >=#2004-03-01# and date <=#2004-03-31#

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #5
Andrew wrote on 29 mrt 2004 in microsoft.public.inetserver.asp.general:
What I am going to do is to select the month or year from the date, for
example,
select * from table where thedate >=#2004-[var]-01# and thedate
<=#2004-[var]-31#
That means all the record in a month. Can you help? Thanks.


What about February, or April for that matter?
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #6
That makes no sense. What you should do is pass a start and end date to the
query, like this:

select <list of fields> from table
where thedate >= [pStart] and theDate <=[pEnd]

When you test this in Access, you will get prompted for the two dates. Save
the query as qRecordsInDateRange. In ASP, call it by:

dim rs, cn
set cn=server.createobject("adodb.connection")
cn.open "<valid connection string>"
set rs=server.createobject("adodb.recordset")
cn.qRecordsInDateRange "2004-03-01#,#2004-03-31#,rs

HTH,
Bob Barrows
Andrew wrote:
What I am going to do is to select the month or year from the date,
for example,
select * from table where thedate >=#2004-[var]-01# and thedate
<=#2004-[var]-31#
That means all the record in a month. Can you help? Thanks.
"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Andrew wrote:
Hi,
I select from an Access table " where date >= '3/1/2004' and date
<='3/31/2004' ", but no record. Can you tell me how to make this
comparission?
Thanks

Jet requires you to use # to delimit literal dates. You should use
ISO date format, like this:

where date >=#2004-03-01# and date <=#2004-03-31#
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so
I don't check it very often. If you must reply off-line, then remove
the "NO SPAM"


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #7
Bob Barrows [MVP] wrote on 29 mrt 2004 in
microsoft.public.inetserver.asp.general:
That makes no sense. What you should do is pass a start and end date
to the query, like this:

select <list of fields> from table
where thedate >= [pStart] and theDate <=[pEnd]


What about the "between" keyword ?

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #8
Evertjan. wrote:
Bob Barrows [MVP] wrote on 29 mrt 2004 in
microsoft.public.inetserver.asp.general:
That makes no sense. What you should do is pass a start and end date
to the query, like this:

select <list of fields> from table
where thedate >= [pStart] and theDate <=[pEnd]


What about the "between" keyword ?

Either way.
Aaron has lobbied against the use of "between", and while I personally have
no problem with it, other users might. Since the OP started off using this
method, I saw no reason to suggest otherwise.

One thing I neglected to suggest to the OP: if users are entering times as
well as dates into thedate, then the above query should be changed to:

select <list of fields> from table
where thedate >= [pStart] and theDate <dateadd("d",1,[pEnd])

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jul 19 '05 #9
How can I select the records containing March(or 03) in theDate, for
example, 03/21/2004, 03/12/1996. Can I do that? Thanks anyway.

--
Andrew
"Bob Barrows [MVP]" <re******@NOyahoo.SPAMcom> wrote in message
news:O1**************@TK2MSFTNGP12.phx.gbl...
Evertjan. wrote:
Bob Barrows [MVP] wrote on 29 mrt 2004 in
microsoft.public.inetserver.asp.general:
That makes no sense. What you should do is pass a start and end date
to the query, like this:

select <list of fields> from table
where thedate >= [pStart] and theDate <=[pEnd]

What about the "between" keyword ?

Either way.
Aaron has lobbied against the use of "between", and while I personally

have no problem with it, other users might. Since the OP started off using this
method, I saw no reason to suggest otherwise.

One thing I neglected to suggest to the OP: if users are entering times as
well as dates into thedate, then the above query should be changed to:

select <list of fields> from table
where thedate >= [pStart] and theDate <dateadd("d",1,[pEnd])

Bob Barrows

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jul 19 '05 #10
Andrew wrote on 30 mrt 2004 in microsoft.public.inetserver.asp.general:
How can I select the records containing March(or 03) in theDate, for
example, 03/21/2004, 03/12/1996. Can I do that? Thanks anyway.

... WHERE MONTH(theDate) = 3

[Not in Jet, I think]
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #11
Well, that's a different problem. If this is a search that will need to be
done quite often, and your table is likely to hold more than several hundred
records, I would consider a slight denormalization of your table: create a
new column that contains the month. A simple update query can be used to
populate it:

update table
set monthcolumn=month(thedate)

or

update table
set monthcolumn = datepart("m",thedate)

Put an index on the column and searches for March data will be very fast.
Unfortunately, you add the complication of needing to update this column
every time you add data to the table or update the thedate column. This is
the trade-off you need to consider: is the improved performance of the
search query worth the extra complication imposed by denormalizing your
table?

If you cannot add the column, or you determine that you don't need it, then
you have no choice but to force a table scan by using either the month() or
datepart() function on your column in the WHERE clause:

WHERE month(thedate)=3

or

WHERE datepart("m",thedate) = 3

HTH,
Bob Barrows

Andrew wrote:
How can I select the records containing March(or 03) in theDate, for
example, 03/21/2004, 03/12/1996. Can I do that? Thanks anyway.


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #12
Thanks, I prefer option 1.

--
Andrew
"Bob Barrows" <re******@NOyahoo.SPAMcom> wrote in message
news:OS**************@TK2MSFTNGP12.phx.gbl...
Well, that's a different problem. If this is a search that will need to be
done quite often, and your table is likely to hold more than several hundred records, I would consider a slight denormalization of your table: create a
new column that contains the month. A simple update query can be used to
populate it:

update table
set monthcolumn=month(thedate)

or

update table
set monthcolumn = datepart("m",thedate)

Put an index on the column and searches for March data will be very fast.
Unfortunately, you add the complication of needing to update this column
every time you add data to the table or update the thedate column. This is
the trade-off you need to consider: is the improved performance of the
search query worth the extra complication imposed by denormalizing your
table?

If you cannot add the column, or you determine that you don't need it, then you have no choice but to force a table scan by using either the month() or datepart() function on your column in the WHERE clause:

WHERE month(thedate)=3

or

WHERE datepart("m",thedate) = 3

HTH,
Bob Barrows

Andrew wrote:
How can I select the records containing March(or 03) in theDate, for
example, 03/21/2004, 03/12/1996. Can I do that? Thanks anyway.


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"

Jul 19 '05 #13

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

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...
8
by: peashoe | last post by:
I have an asp page that uses a calendar.js (pop-up) file to add an exact date format in the text field (txtDDate). My problem is I need some javascript that sets an alert that does not allow them...
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...
12
by: Steve Elliott | last post by:
I have a query set up to gather together data between two specified dates. Shown in the query column as: Between #24/09/2004# And #01/10/2004# Is it possible to enter several different date...
3
by: manning_news | last post by:
Using A2K. I've been asked to modify a report currently requiring only one date parameter to now accept a date range. The main report has 2 subreports and is not bound to a table or query. The...
6
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...
18
by: dfetrow410 | last post by:
Anyone have some code that will do this? Dave
19
by: ali3n8 | last post by:
Hello I have attempted to create a date range report from a query called qrycustomerinformation. The field that contains the value of my date is called Followup. When i run a report on this it is...
4
Sandboxer
by: Sandboxer | last post by:
I want to be able to program Access to provide for me, by individual day, what my contract obligations are to my customers. Will Access recognize all the individual days in between a date range...
2
by: grego9 | last post by:
I have a problem in Excel 2000. I have written some VBA code that transfers data from the current excel workbook to a file called "Deal Input2.xls". Everything transfers ok apart from the date in...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.