Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Calculate the Amount of Days Between Two Dates

Author  Topic 

cnbhold
Starting Member

43 Posts

Posted - 2011-05-25 : 00:33:43
I need to create a query that will calculate the number of days between two dates.

Table Name: Dates

Table Structure

Date1 (date)
Date2 (date)
NumberOfDays (int)

Sample Data

Date1 ..........Date2 .........NumberofDays
2011-5-5........2011-5-10..........5
2011-5-15......2011-5-21..........6

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-05-25 : 02:00:48
select datediff(day,Date1,Date2)


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

cnbhold
Starting Member

43 Posts

Posted - 2011-05-25 : 05:57:54
That worked. Thanks!
Go to Top of Page
   

- Advertisement -