Reg: Find no of months for the present quarter given start date and end date.

  • 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.

  • 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/61537
  • 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:

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • Thanks dude

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply