By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,107 Members | 1,318 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,107 IT Pros & Developers. It's quick & easy.

Calculate number of days

P: n/a

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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.