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)
 moth diff

Author  Topic 

jeff06
Posting Yak Master

166 Posts

Posted - 2008-08-28 : 13:57:45

How to calulate month diffence between two formats:
'10/23/2008' and '2007/08'?
Thanks.
Jeff

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-28 : 14:05:46
use DATEDIFF after converting them to datetime using CONVERT function.
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2008-08-28 : 14:06:42
Those are strings so
SELECT DATEDIFF(MONTH,'10/23/2008,'2008/08' + '/01')

Jim
Go to Top of Page

Arnold Fribble
Yak-finder General

1961 Posts

Posted - 2008-08-28 : 17:09:17
moth diff?
Butterflies have blobs on the ends of the their antennae.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-29 : 03:13:05
quote:
Originally posted by jimf

Those are strings so
SELECT DATEDIFF(MONTH,'10/23/2008,'2008/08' + '/01')

Jim


SELECT DATEDIFF(MONTH,'10/23/2008','2008/08' + '/01')

Madhivanan

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

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-08-29 : 03:13:26
quote:
Originally posted by Arnold Fribble

moth diff?
Butterflies have blobs on the ends of the their antennae.





Madhivanan

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

- Advertisement -