473,586 Members | 2,678 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date Range in Access not working

5 New Member
Hey... googled my problem and got this site...

I am new to SQL and pretty much "winging it" as far as learning...

I have set the format on my field to mm/dd/yy to match the data that is returned.
I am using >= #mm/dd/yy# in my criteria, being >= '#06/30/07#' because I only want to see things bought the last 6 months of the year.

everything seems to look right. However, it is returning a few items from 2005? I have tried just about everything i can think of... I have posted the SQL below for suggestions!!! Thanks in advance!!!
Expand|Select|Wrap|Line Numbers
  1. SELECT OAUSER_ITEM.ITEM_NUMBER, OAUSER_ITEM.ITEM_DESC, OAUSER_ITEM.ITEM_DESC_2, OAUSER_ITEM.CURRENT_COST, OAUSER_ITEM.QTY_ONHAND, OAUSER_ITEM_HISTORY.LAST_PURCH_DATE
  2. FROM OAUSER_ITEM LEFT JOIN OAUSER_ITEM_HISTORY ON OAUSER_ITEM.ITEM_NUMBER = OAUSER_ITEM_HISTORY.ITEM_NUMBER
  3. WHERE (((OAUSER_ITEM.QTY_ONHAND)<>0) AND ((OAUSER_ITEM_HISTORY.LAST_PURCH_DATE)>="#06/30/07#"));
Jan 21 '08 #1
10 2153
MindBender77
234 New Member
Hey... googled my problem and got this site...

I am new to SQL and pretty much "winging it" as far as learning...

I have set the format on my field to mm/dd/yy to match the data that is returned.
I am using >= #mm/dd/yy# in my criteria, being >= '#06/30/07#' because I only want to see things bought the last 6 months of the year.

everything seems to look right. However, it is returning a few items from 2005? I have tried just about everything i can think of... I have posted the SQL below for suggestions!!! Thanks in advance!!!

SELECT OAUSER_ITEM.ITE M_NUMBER, OAUSER_ITEM.ITE M_DESC, OAUSER_ITEM.ITE M_DESC_2, OAUSER_ITEM.CUR RENT_COST, OAUSER_ITEM.QTY _ONHAND, OAUSER_ITEM_HIS TORY.LAST_PURCH _DATE
FROM OAUSER_ITEM LEFT JOIN OAUSER_ITEM_HIS TORY ON OAUSER_ITEM.ITE M_NUMBER = OAUSER_ITEM_HIS TORY.ITEM_NUMBE R
WHERE (((OAUSER_ITEM. QTY_ONHAND)<>0) AND ((OAUSER_ITEM_H ISTORY.LAST_PUR CH_DATE)>="#06/30/07#"));

I believe it could be one of two things:

First, the OAUSER_ITEM_HIS TORY.LAST_PUCH_ DATE might not be a set under the correct date format. Second, try removing the quotes from "#06/30/07#"
Jan 21 '08 #2
AsheboroAlli
5 New Member
I believe it could be one of two things:

First, the OAUSER_ITEM_HIS TORY.LAST_PUCH_ DATE might not be a set under the correct date format. Second, try removing the quotes from "#06/30/07#"
how do you change the date format for OAUSER_ITEM_HIS TORY.LAST_PUCH_ DATE?????
Jan 21 '08 #3
jaxjagfan
254 Recognized Expert Contributor
Hey... googled my problem and got this site...

I am new to SQL and pretty much "winging it" as far as learning...

I have set the format on my field to mm/dd/yy to match the data that is returned.
I am using >= #mm/dd/yy# in my criteria, being >= '#06/30/07#' because I only want to see things bought the last 6 months of the year.

everything seems to look right. However, it is returning a few items from 2005? I have tried just about everything i can think of... I have posted the SQL below for suggestions!!! Thanks in advance!!!

SELECT OAUSER_ITEM.ITE M_NUMBER, OAUSER_ITEM.ITE M_DESC, OAUSER_ITEM.ITE M_DESC_2, OAUSER_ITEM.CUR RENT_COST, OAUSER_ITEM.QTY _ONHAND, OAUSER_ITEM_HIS TORY.LAST_PURCH _DATE
FROM OAUSER_ITEM LEFT JOIN OAUSER_ITEM_HIS TORY ON OAUSER_ITEM.ITE M_NUMBER = OAUSER_ITEM_HIS TORY.ITEM_NUMBE R
WHERE (((OAUSER_ITEM. QTY_ONHAND)<>0) AND ((OAUSER_ITEM_H ISTORY.LAST_PUR CH_DATE)>="#06/30/07#"));
Don't put (") quotes around your date.

((OAUSER_ITEM_H ISTORY.LAST_PUR CH_DATE)>=#06/30/07#));

If you are working in the query builder in Access you don't need to include the # signs, Access will include automatically if it needs.
Jan 21 '08 #4
AsheboroAlli
5 New Member
If I take out just the ' marks, if I take out just the #;s, and if I take out both it doesn't return anything for any option???
Jan 21 '08 #5
MindBender77
234 New Member


how do you change the date format for OAUSER_ITEM_HIS TORY.LAST_PUCH_ DATE?????
You have to view the table in "design view". This is where each column of the table is assigned a data type.

NOTE: I would not change table settings for it might cause you greater problems.

I would first start with removing the double quotes first. If they reappear after you remove them.

This would indicate that the OAUSER_ITEM_HIS TORY.LAST_PUCH_ DATE is set to a Text data type in the table design. It order to get the results you want, the data type this field must be set to date and formatted to be mm/dd/yy

JS
Jan 21 '08 #6
AsheboroAlli
5 New Member
The data type in Design View under properties is set to mm/dd/yy to match the info returned by Query...

is this what you mean... if not how would I change it from text to mm/dd/yy???

again, thank you for all of your help!
Jan 21 '08 #7
jaxjagfan
254 Recognized Expert Contributor
Try this:
If LAST_PURCH_DATE is in a viable date/string format then CDate function will convert it to a true date format.
Expand|Select|Wrap|Line Numbers
  1. SELECT OAUSER_ITEM.ITEM_NUMBER, OAUSER_ITEM.ITEM_DESC, OAUSER_ITEM.ITEM_DESC_2, OAUSER_ITEM.CURRENT_COST, OAUSER_ITEM.QTY_ONHAND, OAUSER_ITEM_HISTORY.LAST_PURCH_DATE
  2. FROM OAUSER_ITEM LEFT JOIN OAUSER_ITEM_HISTORY ON OAUSER_ITEM.ITEM_NUMBER = OAUSER_ITEM_HISTORY.ITEM_NUMBER
  3. WHERE (OAUSER_ITEM.QTY_ONHAND)<>0) AND (CDate(OAUSER_ITEM_HISTORY.LAST_PURCH_DATE)>=#06/30/2007#);
Jan 21 '08 #8
AsheboroAlli
5 New Member
Try this:
If LAST_PURCH_DATE is in a viable date/string format then CDate function will convert it to a true date format.

SELECT OAUSER_ITEM.ITE M_NUMBER, OAUSER_ITEM.ITE M_DESC, OAUSER_ITEM.ITE M_DESC_2, OAUSER_ITEM.CUR RENT_COST, OAUSER_ITEM.QTY _ONHAND, OAUSER_ITEM_HIS TORY.LAST_PURCH _DATE
FROM OAUSER_ITEM LEFT JOIN OAUSER_ITEM_HIS TORY ON OAUSER_ITEM.ITE M_NUMBER = OAUSER_ITEM_HIS TORY.ITEM_NUMBE R
WHERE (OAUSER_ITEM.QT Y_ONHAND)<>0) AND (CDate(OAUSER_I TEM_HISTORY.LAS T_PURCH_DATE)>= #06/30/2007#);

It says that there is a data type mismatch in criteria expression error? ...

This is ridiculous... I cannot figure this out to save my life...

sheesh...
Jan 22 '08 #9
jaxjagfan
254 Recognized Expert Contributor
It says that there is a data type mismatch in criteria expression error? ...

This is ridiculous... I cannot figure this out to save my life...

sheesh...
With the Mismatch error then the "actual data" is not in a recognizable date format. This may not be true for all records tho. Are some of the date values Null, some other value or multiple input variations (I.E. "Missing Date", "Error", 2008/01/15, 010108, etc,)? This can cause the calculations to fail.

Sort the data by that date column in ascending order and look at the dates and then in descending order and lokk at dates. You may find some records with erroneous entries or formats the may need correcting first.
Jan 22 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

7
682730
by: vnl | last post by:
I'm trying to run a SQL query but can't find any records when trying to select a certain date. Here's the sql: SELECT field 1, field2, date_and_time, FROM table1 WHERE date_and_time = '01-SEP-02' I'm getting no results. The date_and_time field is formatted like this: 2002-SEP-02 00:01:04
5
14883
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 geographical region. I have written a query which prompts the user for the start and end dates. It also filters for entries which pertain to the particular...
12
6359
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 ranges, ie between 24/09/2004 and 01/10/2004 together with 05/10/2004 and 07/10/2004 ? If I enter the "Between" criteria on different lines it...
3
7451
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 report prints dental and hygenist appointments for the date (one subreport for each). The user wants to enter a date range and have one page for each...
8
3623
by: John Wildes | last post by:
Hello all I'm going to try and be brief with my question, please tell me if I have the wrong group. We are querying transaction data from a DB3 database application. The dates are stored as text fields. Each date for example 10/31/03 or October 31st 2003 is stored as 10/31/A3 in the system. My reasoning for this is because they...
67
7647
by: PC Datasheet | last post by:
Transaction data is given with date ranges: Beginning End 4/1/06 4/4/06 4/7/06 4/11/06 4/14/06 4/17/06 4/18/06 4/21/06 426/06 4/30/06 I am looking for suggestions on how to find the date ranges where there were no transactions.
0
1441
by: rdemyan via AccessMonster.com | last post by:
I have a need to highlight a date range in a bar chart. If the "highlighting" is accomplished by changing the bar column color for the specific months in the date range, that would be great. Here's an example: I'm plotting meter usage against dates on the chart. The dates are typically the first day of the month. So assume the chart...
1
1707
by: Thorben Grosser | last post by:
Hey again newsgroup, I am still working on an archive database and got another problem: I have to classify the folders by a date or a date range which has the format mm/yyyy I got the feeling, that I should try at every price to also use the date/time field as it offers many benefits like easy searching or automatic controlling of values....
4
2846
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 (simply a "from" date and a "to" date)? Additionally, I need to delivery a specific quantity of product when the customer's inventory is within about...
3
2326
by: Deano | last post by:
The short version; In short, given one date range (start and end dates) how can I find the period that overlaps with another date range? The long version; I have knocked up a little application that helps my friend monitor employee absences. You can enter the start and end dates of an absence. For reports the user specifies start and...
0
7839
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...
1
7959
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
8216
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6614
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...
1
5710
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
5390
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
3837
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
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
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.