Calculating No of days passed from getdate()

Posted on 2008-11-06
Last Modified: 2012-05-05

I am using MSSQL 2005

I want no of days passed from the given date for example

If getdate() = 6 Nov

and pastDate = '2008-10-03 00:00:00.000'

Then I want no of days passed in integer

I am writting below query which is giving me date. But I want integer value, which tell no of days passed

select getDate()- CONVERT(datetime, '2008-10-03 00:00:00.000')

Thanks in Advance
Question by:tia_kamakshi
    LVL 7

    Accepted Solution

    select datediff(dd,'2008-10-03',getdate())
    LVL 14

    Assisted Solution

    try this
    declare @dt as datetime
    set @dt = cast('2008-10-03 00:00:00.000' as datetime)
    select ABS(datediff(day,@dt,getDate()))

    Open in new window


    Author Closing Comment

    Many Thanks

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    As they say in love and is true in SQL: you can sum some Data some of the time, but you can't always aggregate all Data all the time! Introduction: By the end of this Article it is my intention to bring the meaning and value of the above quote to…
    If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    737 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

    19 Experts available now in Live!

    Get 1:1 Help Now