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
 Difference in the dates...

Author  Topic 

challapavan
Starting Member

8 Posts

Posted - 2007-10-23 : 14:39:05
I have 2 datatime columns....i want to get the difference in the dates...

EXample

Startdate Enddate Difference

10/10/2007 20/10/2007
11/10/2007 21/10/2007
12/10/2007 22/10/2007
13/10/2007 23/10/2007
14/10/2007 25/10/2007


I want the difference to be in the Difference column...

Kindly help me...thanks in advance...

pavan

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-10-23 : 14:42:42
Use the DATEDIFF function.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-10-23 : 14:54:05
There's a whole article about that here:

http://www.sqlteam.com/article/working-with-time-spans-and-durations-in-sql-server


- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

kiruthika
Yak Posting Veteran

67 Posts

Posted - 2007-10-24 : 05:16:25
Hi!
select datediff(day,startdate,enddate) from mytable
Happy Programming!
Go to Top of Page
   

- Advertisement -