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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 finding differnce between two date

Author  Topic 

imranabdulaziz
Yak Posting Veteran

83 Posts

Posted - 2008-09-09 : 05:28:10
Hi,
I am using sql server 2005.
When I am finding difference between two date I am getting one day less
For example
select datediff(d , '2008-09-01' , '2008-09-05')
I am getting 4 days I want it to be five day as 1,2,3,4,5 that is it should start from date to todate


How can I do it

Please help
thank you

sunil
Constraint Violating Yak Guru

282 Posts

Posted - 2008-09-09 : 05:29:24
http://weblogs.sqlteam.com/jeffs/archive/2007/10/15/time-spans-durations-sql-server.aspx
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-09 : 05:35:50
If you want to include the first date for counting,

select datediff(d , '2008-09-01' , '2008-09-05')+1

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -