473,385 Members | 1,888 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.

between date criteria not working

222 100+
Dear All

I am using this function to make the sum of values in my query

Expand|Select|Wrap|Line Numbers
  1. nz(DSum("Total","fuel_move","id_fuel_move='"  & barcode_product & "'" & "and date_fuel_move between" & [date1] And [date2]  ),0) AS sofuel
I am not getting the right values!!!

When I am using this part of the function
Expand|Select|Wrap|Line Numbers
  1. "and date_fuel_move between" & [date1] And [date2]
the first part of the criteria will be eliminated and printing me just one value.

How may I fix that ?

Any hint would be appreciated.

REGARDS
Mar 20 '09 #1
4 3955
OldBirdman
675 512MB
If barcode_product were xxxxxx and date1 were 3/1/09 and date2 were 3/15/09, then
Expand|Select|Wrap|Line Numbers
  1. nz(DSum("Total","fuel_move","id_fuel_move='"  & barcode_product & "'" & "and date_fuel_move between" & [date1] And [date2]  ),0) AS sofuel 
with substitutions would be
Expand|Select|Wrap|Line Numbers
  1. nz(DSum("Total","fuel_move","id_fuel_move='xxxxxx'and date_fuel_move between0),0) AS sofuel 
Without going any further into the problem, I see several syntax errors here. I'm using the ~ as a delimeter to avoid confusion with the single and double quotes that already appear in the statement.
1) There needs to be a blank between ~'xxxxxx'~ and ~"and date_..."~ so change to ~" and date_. . ."~
2) ~[date1] and [date2]~ will evaluate to False, or 0 unless both dates are the same, then it will evaluate to True. The center ~And~ needs to be ~ & " And " & ~
3) Date values need the delimeter "#" so they are correctly intrepreted as dates, and not arithemetic operations. ~[date1]~ should be ~" #" & [date1] & "#"~ ~[date2]~ needs similar changes.
Mar 21 '09 #2
NeoPa
32,556 Expert Mod 16PB
Nice work OB. It's a shame the OP hasn't returned to thank you themselves but you get that sometimes.

A helpful link on this subject is Literal DateTimes and Their Delimiters (#).
Apr 4 '09 #3
OldBirdman
675 512MB
Thankx NeoPa. I read these posts to learn. Very selfish of me. By considering whether I want to reply, I make myself study the problems carefully. I therefore improve myself. That is my reward.
Apr 5 '09 #4
NeoPa
32,556 Expert Mod 16PB
Yeah OB, you're all just self, self, self! :D

I'm glad to hear you're not likely to be put off from such threads though, and I know what you mean about learning. Working on this site has given me a much deeper understanding of various aspects of Access that I had never covered in my own work.
Apr 5 '09 #5

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

Similar topics

1
by: Jaycee66 | last post by:
Access 2000 "Between" query question: I am relatively new to MS Access and everytime I think I have a basic concept of the program it pokes me in the eye with something I think would be simple to...
11
by: David B | last post by:
I have 2 querys with the following in the date criteria Between DateAdd("m",-6,(!!)) And (!!) Between DateAdd("m",-24,(!!)) And DateAdd("m",-6,(!!)) Problem is they both look at the same...
2
by: Enterprise | last post by:
Can you use Between to include all dates some how in a query criteria? I use Between Get_Date1() and Between Get_Date2(). Some of my fields in the column are empty. Therefore no matter what date...
6
by: Tony Williams | last post by:
I have a query with this Between statement as the criteria: "Between And " If I key in June 2002 as the first quarter date and June 2004 as the second quarter date I get data for June 2002 upto...
5
by: DW | last post by:
I have a query in Access 2003 that has the following criteria SELECT tblOrder.SessionDate, tblMenus.Item_Name, tblOrder.Type, Format$(tblorder!SessionDate,"Short Time") AS SessionTime,...
13
by: Jim Armstrong | last post by:
Hi all - This problem has been driving me crazy, and I'm hoping the answer is something stupid I am neglecting to see.... The procedure posted below is part of an Access/SQL database I have...
2
by: Carl | last post by:
Hi, I have a query that produces an output similar to the sample shown below. These records are based on certain criteria and a date range selected from a form. I need to create some kind of...
1
by: Blue Lagoon Products - Customer Services | last post by:
Hi, I am in a bit of a pickle...I need to know the Total figure of the gross field in my table between 2 dates specified in a query. I need to know what criteria to put into my query on the...
8
by: Dr Al | last post by:
I have a table with four date fields, some of which may not be filled in based on our data entry needs. I have a criteria set as <date()-180 which is supposed to pull dates older than 180 days ago....
2
by: falroc | last post by:
I have a data base that is used for billing. I have a form called a report selector form. Below is the code used to create the report from the user inputs on the form. What I want to do is add a...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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
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...

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.