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 2012 Forums
 Transact-SQL (2012)
 Date Duration

Author  Topic 

chiragvm
Yak Posting Veteran

65 Posts

Posted - 2014-12-18 : 05:23:04
Hi to all

i have to display duration between startdate and EndDate
for that i am use DATEDIFF of week it will give me a int value like 3 week , 2 week
but DATEDIFF of days is 23 then result like 3 Week, 2 days


-------------
Chirag
India
Sr.Software Engineer

Muj9
Yak Posting Veteran

75 Posts

Posted - 2014-12-18 : 06:53:34
select convert(varchar(20), convert(varchar(10),datediff(DAY,'20140101','20140124')/7) + 'Week'+' '+ convert(varchar(10),datediff(DAY,'20140101','20140124')%7))+' '+ 'Days'
Go to Top of Page
   

- Advertisement -