add/sub value of 2 columns and get difference

Posted on 2005-04-27
Last Modified: 2010-05-18
Ok, I have it down, on how to perform my update for dates, based on column values:

        UPDATE TL_Calibration SET [Next Calib] = DATEADD(day, InspectionFrequency, [Last Calibrated])

The question I have now is how to take two columns, with date values, and insert the difference into a column.  Here is an example of what I am talking about:

[Last Calibrated]        [Next Calib]    =     Days
    04/01/05                04/05/05                4       <------WHERE "4" IS HOW MANY DAYS LEFT      
Question by:chrisryhal
    LVL 28

    Accepted Solution

    UPDATE YourTable
    SET DaysLeft = DATEDIFF(DD, [Last Calibrated], [Next Calib])
    LVL 2

    Author Comment


    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
    For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
    Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
    Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

    755 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

    17 Experts available now in Live!

    Get 1:1 Help Now