March 7, 2012 at 2:21 am
Hi,
I need a query or function which returns number of months for the present quarter, given a date range.
Example
Start Date = 2010-01-01
End Date = GETDATE()
Function should return 2 and not 26 as we are in the month of March 2012.
Appreciate your quick response.
Thanks a Lot in advance.
Cheers,
Mohan.
March 7, 2012 at 2:29 am
Try taking the result mod 12
SELECT DATEDIFF(Month,'20100101',GETDATE()) % 12
____________________________________________________
Deja View - The strange feeling that somewhere, sometime you've optimised this query before
How to get the best help on a forum
http://www.sqlservercentral.com/articles/Best+Practices/61537March 7, 2012 at 5:29 am
mohanbvs (3/7/2012)
Hi,I need a query or function which returns number of months for the present quarter...
Strange, I always thought that any quarter contains 3 months. You kind of need no function for this... :hehe:
March 7, 2012 at 7:47 am
Thanks dude
Viewing 4 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply