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

How do I add a calculated field that calculates a number of days?

I need to calculate a shipping efficency. I have two sets of data, OrderDate and ShipDate, I need to Figure out how long it took each order to ship. Essientially I need to minus the Ship date from the Order date in a new field, entitiled "DaysToShip". I'm new to access, so thank you for the help!!

P.s. If you need more information or I'm not being clear please let me know.
Apr 27 '12 #1
5 7440
NeoPa
32,556 Expert Mod 16PB
Are these two sets of data fields in a single table? The table name would help if so. I'm also assuming you want to create a query to show both the table fields and the calculated field [DaysToShip]. If so, your query would look something like :
Expand|Select|Wrap|Line Numbers
  1. SELECT [OrderDate]
  2.      , [ShipDate]
  3.      , DateDiff('d',[OrderDate],[ShipDate]) AS [DaysToShip]
  4. FROM   [YourTable]
Apr 27 '12 #2
As you wand to minus the shipped date I think this code will help you
Expand|Select|Wrap|Line Numbers
  1. SELECT [OrderDate]
  2. , [ShipDate]
  3. , DateDiff('dd',[OrderDate],[ShipDate]-1) AS [DaysToShip]
  4. FROM [YourTable]
In Access Query Desing View Try This code, It may work
Expand|Select|Wrap|Line Numbers
  1. select DateDiff(dd,OrderDate,ShippedDate)-1
Apr 29 '12 #3
NeoPa
32,556 Expert Mod 16PB
@Roshan.
As you have simply used my suggested code with a couple of minor changes let me just deal with the changes :
  1. You changed 'd' to 'dd'. This simply makes the call fail as 'dd' is not a valid parameter to DateDiff().
  2. You subtracted one from the calculation. This simply causes the calculation to give an incorrect result.
In your second suggestion you took dd out of the quotes. This simply makes no sense and cannot possibly work (without a predefined object / field named dd which is not the case here).
Apr 29 '12 #4
The sugestion work in case Of MySql Check the code.Thanks for comment
Apr 29 '12 #5
NeoPa
32,556 Expert Mod 16PB
This is an Access question in an Access forum and it doesn't work in Access. I'm pretty sure nothing else is relevant.
Apr 29 '12 #6

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

Similar topics

5
by: Richard Holliingsworth | last post by:
Hello: Thanks for reading this post. I need to create a metrics (form or report - I don't care which) to display calculated fields about the database (A2002 front end to SQL Server 2K) 1) I...
1
by: Judy | last post by:
I have the following table in part --- TblClassDate ClassDateID CourseID ClassDate Classes for courses are held on multiple days. The data for a course in the table might look like:...
2
by: EdDale | last post by:
Hi and thanks in advance, I am using DMin and DMax to calculate date fields in a form. I need to use these calculated dates in another calculated field. example: =DMax("","B&MPayPeriod"," >=...
5
by: Henrik | last post by:
The problem is (using MS Access 2003) I am unable to retrieve long strings (255 chars) from calculated fields through a recordset. The data takes the trip in three phases: 1. A custom public...
1
by: Steve Harp | last post by:
Hi All, I'm not sure this can be done in a calculated field but here's what I need. I have a table that stores time off for employees (such as vacation, sick time, etc). An employee can take...
5
by: CSmith | last post by:
I have a calculated field in a query, it calculates the # of days an employee has been employed using the following statement =datediff("d", , NOW()) by default. When an employee is terminated, I...
3
by: myemail.an | last post by:
I use Access 2007 and create queries with a number of calculated fields/expressions (I'm still a novice so please forgive me if my wording is imprecise...), like: MyCalculation = Field1 - Field2. ...
1
by: Greg (codepug | last post by:
Access 2000 Using a textbox of a single form, I created a calculated field. The following code is in the Control Source for this field: =IIf(=24,+(/),/ ) The numbers that are calculated are...
5
by: Nour469 | last post by:
Hello, This was supposed to be easy but I could not get it! I need to create a calculated field in Access (preferably in a table or maybe a query) that calculates the BMI. I have fields for the...
2
by: mkbrady | last post by:
I have a query that includes calculated fields that generate numeric results. I have wrapped conversion functions CLng() and CDdl() around the calculated fields to ensure the data types are...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.