Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the month numbers for the current quarter

I need an array with the numbers for the months in the current quarter. I want to supply Date.today and then get eg. [1,2,3].

How do I do that in the easiest way? (Not by using switch/case).

like image 458
jriff Avatar asked Jun 12 '11 13:06

jriff


People also ask

How to get the quarter from date in Excel?

Find and get quarter from date by formula Select a blank cell which next to the date, here I select C1, and type this formula =ROUNDUP(MONTH(A1)/3,0) into it, then press Enter key to get the relative quarter.


1 Answers

def quarter(date)
  1 + ((date.month-1)/3).to_i
end
like image 55
bob Avatar answered Oct 29 '22 05:10

bob