473,549 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4472
"Tony" <an************ **@ama.ab.ca> wrote in message
news:6d******** *************** ***@posting.goo gle.com...
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
5203
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
7
3148
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 dates in UK date format to input into the database. In Enterprise Manager on the SQL Server I can manually enter a record into a table and just...
8
2662
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 to select today. example: var dtToday = Date() if(document.frmSoftware.txtDDate.value == dtToday) {
4
22657
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 that there are different start days of the week so I would presume any function would provide that facility. Hope you can help Mark
5
4480
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 user to specify criteria for viewing the report. The one I am having problems with is the date. I allow the user to set a date range, so for...
15
18870
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 the value in timeonly format by using this command Format(now,"HH:mm:ss") But when I insert it into the Sql Server database, it embadded date value...
1
9112
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 a table in Access with four fields
2
3880
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 data based on this range. i.e.
11
6173
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 days), weekly (for the last 6 weeks) and monthly (for the last 6 complete months). Daily and monthly are not causing me a problem - I have used the...
19
6002
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 original tread http://bytes.com/topic/access/answers/872005-query-date-range Just to clarify what I am trying to achieve....
0
7548
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
7743
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. ...
0
7986
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7504
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...
1
5391
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...
0
5114
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...
0
3518
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...
1
1965
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
0
786
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.