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

Date format range

Hey guys,

I use Google Groups quite a bit as it is an enormous wealth of
information, and now I need some help. I have created a query using
parameters to capture a range of date, the date is also formatted.

test: Format([archive_date],"mm/dd/yy")

Between [date1:] And [date2:]

This is where it gets wonky, when I enter 05/01/04 for [date:1] and
05/31/04 for [date2:] it pulls the correct MM and DD but the YY is not
right. Basically I get all dates for the month of May, but it captures
it for 2001, 2002, 2003, and 2004. Can anyone help me pull the right
range?
Nov 13 '05 #1
4 4458
"Tony" <an**************@ama.ab.ca> wrote in message
news:6d**************************@posting.google.c om...
Hey guys,

I use Google Groups quite a bit as it is an enormous wealth of
information, and now I need some help. I have created a query using
parameters to capture a range of date, the date is also formatted.

test: Format([archive_date],"mm/dd/yy")


Problem here is that the Format() function is converting the date to a
string so your BETWEEN clause is going to be an alphabetical test instead
of a date test.

If you just want to strip off the time component and leave it as a date
(formatting doesn't matter in a date test) you can try to use DateValue()
instead of Format().

However; as a "best practice" one should avoid using criteria against an
expression, but instead apply a criteria to the raw field value. The
reason is that as soon as you use an expression (even a very simple one)
the database engine is forced to do a table scan instead of being able to
use an index on the field.

If the field having criteria applied to it doesn't have an index then it
wouldn't matter, but that would be another design flaw (IMO) as searched
and joined fields should always have an index.

A search criteria that could still use an index would look like...

WHERE [archive_date] BETWEEN [date 1] AND DateAdd("d", 1, [date 2])

Notice how in this case I have an expression in the criteria but the
criteria is applied against a raw field instead of a field wrapped in an
expression.
--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #2
On 3 Aug 2004 10:36:47 -0700, Tony wrote:
Hey guys,

I use Google Groups quite a bit as it is an enormous wealth of
information, and now I need some help. I have created a query using
parameters to capture a range of date, the date is also formatted.

test: Format([archive_date],"mm/dd/yy")

Between [date1:] And [date2:]

This is where it gets wonky, when I enter 05/01/04 for [date:1] and
05/31/04 for [date2:] it pulls the correct MM and DD but the YY is not
right. Basically I get all dates for the month of May, but it captures
it for 2001, 2002, 2003, and 2004. Can anyone help me pull the right
range?


That's strange, because I don't get ANY records returned using your
formatting and criteria, and you may be having other criteria problems
as well.

Once you format the field as you have, Access is going to treat the
[date1:] and [date2:] entries as text, not date/time.

To force a date/time value, open the query in Design View.
On the Menu, click on Query + Parameters
Enter
[date1:] Date/Time
[date2:] Date/Time

This should force the entries as date/time and return just the year
entered.

Of course you could just use a normal 4 digit year parameter entry and
avoid having to add that formatted 2 digit year column.
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #3
Hey fredg,

I just have a question about this:
To force a date/time value, open the query in Design View.
On the Menu, click on Query + Parameters
Enter
[date1:] Date/Time
[date2:] Date/Time


What is the date format for this, I am looking for a parameter that is
in short date format? Thanks so much for the your effort!
Nov 13 '05 #4
On 5 Aug 2004 09:03:37 -0700, Tony wrote:
Hey fredg,

I just have a question about this:
To force a date/time value, open the query in Design View.
On the Menu, click on Query + Parameters
Enter
[date1:] Date/Time
[date2:] Date/Time


What is the date format for this, I am looking for a parameter that is
in short date format? Thanks so much for the your effort!


I doesn't matter what the date format is.
Dates, in Access, are stored as a double number.
Today's date is 38204.

When you set the parameter as Date/Time, you can enter the parameter
in any valid date format, i.e. 7/1/04 or 7-1-04 or 7-1-2004 or July 1,
2004 and Access will return the correct dates.

You wouldn't need to explicitly set the parameter datatype (except in
a Crosstab query) if you weren't formatting the criteria column.
In other words, if you were using your [Archive_Date] column as
criteria, all you would need do is write, as parameter in that column:
Between [StartDate] and [EndDate].
Because [Archive_Date] is a Date datatype, Access can figure out the
entered parameter is a date, not text.

You should get used to using a 4 digit year. Access will interpret 2
digit years from 00 through 29 as 2000 to 2029. However a 2 digit year
of 30 through 99 will be interpreted as 1930 to 1999. At some point
you're going to have to use 4 digits. Why not get used to it now.
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #5

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...
7
by: Niall Porter | last post by:
Hi all, I'm building an ASP app on a Windows 2000/IIS machine which interfaces with our SQL Server 2000 database via OLE DB. Since we're based in the UK I want the users to be able to type in...
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...
4
by: Mark | last post by:
Hi I have been trying to convert the week number to a range of dates that I can use. It should be fairly simple for you guru's out there but for us mere mortals it is beyond our grasp. I know...
5
by: Michelle | last post by:
Hi all I have a report which displays staff absences. An absence record has a start and end date and the type of absence, ie sickness, annual leave. I have created a form which allows the...
15
by: Khurram | last post by:
I have a problem while inserting time value in the datetime Field. I want to Insert only time value in this format (08:15:39) into the SQL Date time Field. I tried to many ways, I can extract...
1
by: flumpuk | last post by:
Hi My job currently requires me to enter data from 300+ forms a month. The system which we used in Excel was slow , and theprevious guy had three workbooks for this job . I have created...
2
by: shannonwhitty | last post by:
I am able to extract dates in the correct format i.e. SELECT CONVERT(VARCHAR(8), GETDATE(), 3) =dd/mm/yy My issue is that my users are selecting a date in this format and I need to select...
11
ollyb303
by: ollyb303 | last post by:
Hello, I am using a dynamic crosstab report to track performance statistics for my company and I have hit a problem. I would like the option to track stats daily (for the last 7 complete...
19
by: phill86 | last post by:
Hi I am re-posting this thread because it has become very confusing and I have got some way to solving the problem so it is a slightly different question from the initial thread. here is the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
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...
0
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...
0
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,...
0
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...
0
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...

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.