What do I use in Sql to replace a subtraction symbol

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Anthony97
    New Member
    • Aug 2009
    • 24

    What do I use in Sql to replace a subtraction symbol

    I am using some code from an access db that works how do I convert it in SQL?
    Below is one line of the code. Thanks as always for your help.

    [Loading Time In]-[order time in] AS [percent of load]
  • nbiswas
    New Member
    • May 2009
    • 149

    #2
    Solution to What do I use in Sql to replace a subtraction symbol

    Use the DATEDIFF function whose general syntax is

    Code:
    DATEDIFF ( datepart , startdate , enddate )
    So for your case the query will be

    Select Datediff(day,[Loading Time In],[order time in]) AS [percent of load]


    Note that I am finding the difference in days. You can find it in hours, minutes, seconds, years, etc.

    For a more detailed knowledge on the DATEDIFF function, please visit

    Transact-SQL reference for the DATEDIFF function. Returns the numerical difference between a start and end date based on datepart.



    Hope this will help you.

    Comment

    Working...