472,989 Members | 3,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,989 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 4432
"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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.