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 2000 Forums
 SQL Server Administration (2000)
 difference between 2 dates

Author  Topic 

Keshaba
Yak Posting Veteran

52 Posts

Posted - 2009-08-20 : 08:58:53
I am using sql server 2005 express.How shall I write a query to find the difference between 2 dates.I tried like this but it didn’t work properly

select datediff(Day,Day(DateOFApp),Day(getdate())) from Beneficary where BID = 1

If todays date is 20-08-2009 i.e the getdate() as in the query
And DateofApp is 1-08-2009
then the result is okay
It is 19

But If I change the month to 07 and other remaining same
Then I get the same result
It is 19 but the result should be 31+19= 50.

How shall I solve the problem


Keshab

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-08-20 : 09:02:08
select datediff(Day, DateOFApp, getdate()) from Beneficary where BID = 1


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -