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

Posted on 2008-11-18
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.
Question by:Becky Edwards
    LVL 84
    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))

    LVL 84

    Accepted Solution

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    This isn't a frequent question on EE. I must have seen it three or four times (among several thousand questions). However, I use this trick quite often, most frequently as a delayed Current event. A form does not expose it's calculation dependenc…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
    In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

    779 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

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now