473,657 Members | 2,479 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 14149
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",No w(),OrderDate)

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

Expr1: DateDiff("d",No w(),[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@amst wist00...

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
4737
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 form has Two textboxes to enter dates From Date - Fdate To Date - TDate
26
4397
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: starttime = Date.parse("Aug 10,2003, 07:07") sdt = new Date(starttime)
2
34345
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 example : the user choses week43 (this week) so somehow i must calculate what date is startdate that week (monday 18th). How do i do this with c# ? all i know is that its-
2
3327
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 of each line means a day, the second stands for the month and the last for the amount of money on the account. so the first line is Februari 9th with an amount of 345. I want to make the program read the textfile with a Scanner. Then it should...
7
25984
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 efficient way for me to do this? -- Thanks, Sam
5
13658
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: http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=11469&objectType=File I kluged up this routine that works: // convert date time into that funny matlab serial date time that starts at jan 1, 0000 private string DT2Matlab(DateTime thisDT)
1
3339
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 after 17 days from startdate of contract. How do I calculate the leave days, that accrue every after 17 days by 1. I'm using ASP and SQL Server 2000 (Query Analyzer) ndindi22
3
5957
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 calculate in the query the amount of weeks and days within the 17 days to show 2 weeks 3 days. I can create the function within excel, (A1 as cell with the days within it) as: =INT(A1/7) & " Weeks, " & MOD(A1,7) & " days" but cant seem to...
4
15721
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
11202
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. How to calculate the Total Number of working Days in a given period . Let us say If i give the period as 08/01/2008 to 08/15/2008, I want total number of working days as 11. Please help me
0
8421
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8844
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8742
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8621
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5643
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4173
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2743
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

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.