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
 Old Forums
 CLOSED - General SQL Server
 No of Days (between todates)

Author  Topic 

mateenmohd
Constraint Violating Yak Guru

297 Posts

Posted - 2004-03-06 : 03:27:58
How can calculate the No of days between two dates in sql query analyzer ?

Ie.

select day(enddate-startdate) NOOFDAYS from tablename


Regards.

Mateen



mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2004-03-06 : 03:39:27
Look up the DATEDIFF function in Books Online. Basically you can say:

SELECT DATEDIFF(d, StartDate, EndDate) AS NoOfDays FROM TableName

The function also lets you specify the intervals you want returned, i.e. days, months, years, etc.

OS
Go to Top of Page

mateenmohd
Constraint Violating Yak Guru

297 Posts

Posted - 2004-03-06 : 03:55:48
thanks.

quote:
Originally posted by mohdowais

Look up the DATEDIFF function in Books Online. Basically you can say:

SELECT DATEDIFF(d, StartDate, EndDate) AS NoOfDays FROM TableName

The function also lets you specify the intervals you want returned, i.e. days, months, years, etc.

OS

Go to Top of Page
   

- Advertisement -