473,396 Members | 2,102 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.

Calculate number of days


I am trying to get a difference between two dates calculated in a query. I
have Sales_Date as the first one, and Date() as the second one. How would I
put the difference of these two days into a field?
I have tried something like this:
DateDiff("d", Now(), Sales_Date)
Then I get an error like this:
"Datatype mismatch in criteria expression". Sales_Date is formatted as a
Date format.
-Thanks for all help
Nov 12 '05 #1
2 14130
If you have this expression in the Field row of your query, then it should work. I just
tried a slightly altered version in the Northwind database, using the Orders table:

DateDiff("d",Now(),OrderDate)

Access volunteered a column alias and placed square brackets around the field name:

Expr1: DateDiff("d",Now(),[OrderDate])

The differences calculated were negative numbers. No biggie. Just reverse the
parameters, as in:

Expr1: DateDiff("d",[OrderDate],Now())

to get a positive number of days. The bottom line is it should work. Your error message
is indicating a datatype mismatch in the criteria row. What type of criteria are you
including?
___________________________________________

"Rimdur" <no****@home.cc> wrote in message news:%XJnb.3194$2o2.18269@amstwist00...

I am trying to get a difference between two dates calculated in a query. I
have Sales_Date as the first one, and Date() as the second one. How would I
put the difference of these two days into a field?
I have tried something like this:
DateDiff("d", Now(), Sales_Date)
Then I get an error like this:
"Datatype mismatch in criteria expression". Sales_Date is formatted as a
Date format.
-Thanks for all help

Nov 12 '05 #2
Rimdur previously wrote:
"Datatype mismatch in criteria expression".


All words count!
The message tells you that the <Criteria> expression is incorrect.

You don't have your expression in a criteria cell do you?

If you want to create a new value it goes in the Field cell (at the top of
a new column).

Peter Russell

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: JP SIngh | last post by:
Hi All I need to calculate the number of working days between the two dates entered on an ASP page. I am not that great a coder in ASP and was wondering if someone can help. Basically the...
26
by: Frank | last post by:
For my website i would like to display the age of my son in years, months, days and hours. For now i manage to get a result for totals. Like the total number of days. This is the beginning: ...
2
by: Rustan | last post by:
Hi Im using GregorianCalendar to find out the current years week numbers. When the user chooses a week number in a dropdown i want to show that week in a table with the corresponding dates. For...
2
by: foleyflint | last post by:
Hello, I'm trying to calculate the interest from a bankaccount which is displayed in a text file as followed: 9 2 345 3 3 300 etc. (there are 19 lines in total) the first number...
7
by: Sam | last post by:
Hi, I use C# in my ASP.NET projects. Here's what I need to do: I want to add x business days to a given date i.e. add 12 business days to today's date. What is the best, fastest and most...
5
by: Beemer Biker | last post by:
I cant seem to get that date into any DateTime to make my calculation directly by subtracting "01-01-0000" from "now". After reading this:...
1
by: ndindi22 | last post by:
Can someone plz help me. I'm working on leave application, have to calculate number of leave days available, starting from Startdate to Enddate of a contract. Where an employee get 1 day leave...
3
by: Libber39 | last post by:
Hi everyone, Have a query on how to calculate the amount of weeks and days contained in a number in an access query. ie: the difference in days between 2 dates amounts to 17 days. I want to now...
4
chandru8
by: chandru8 | last post by:
hi to all if the current month is jan,i need to calculate the number of days of feb is it possible without assigning number of days manually to a variable
4
by: shilpareddy2787 | last post by:
Hello, I have some total values, I want to calculate percenatge of these Total Values. I want to divide the total with No. Of working Days Excluding Saturdays and Sundays in a given period. ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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,...

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.