?
Solved

Subtracting one records field from another. Mar06-Feb06 (variance)

Posted on 2008-11-18
2
Medium Priority
?
409 Views
Last Modified: 2012-05-05
I have two fields with data in them.  I want to create a query, add the two fields, and then subtract one from the other.  I don't know how to do it.
0
Comment
Question by:Becky Edwards
  • 2
2 Comments
 
LVL 85
ID: 22989809
Are the fields in the same "row"? If so, you can create a calculated field. In a blank column of your query grid, in the Name row:

AddFields: (DateField1 + DateField2)

Same for subtracting them:

SubtractFields: DateField1 - DateField2

This would result in your query having two new fields - one named AddFields and one named SubtractFields.

If either of these could contain Null values, you'd want to use the Nz function:

AddFields: (Nz(DateField1,0) + Nz(DateField2, 0))

0
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 375 total points
ID: 22989823
Sorry ... I see that you mention "records" in your question, which would indicate that these are not in the same row. If that's the case then no, you really cannot do this. You could build a subselect that did this, but you'd have to have some sort of Ordering field that would correctly sort your values. If you provided a sample of the data, perhaps we could help further.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question