Charif EL ALAOUI
Charif EL ALAOUI

Reputation: 11

How can I convert month to quarter?

I would like to convert from month to quarter with just using month number. For example: (11 - 4), (5 - 2) (Month - Quarter).

Upvotes: 0

Views: 497

Answers (1)

john
john

Reputation: 56

int(MONTH//3.1)+1

for i in range(1,13) :
    print('month : ',i,'quarter :',int(i//3.1)+1)

will print:

month :  1 quarter : 1
month :  2 quarter : 1
month :  3 quarter : 1
month :  4 quarter : 2
month :  5 quarter : 2
month :  6 quarter : 2
month :  7 quarter : 3
month :  8 quarter : 3
month :  9 quarter : 3
month :  10 quarter : 4
month :  11 quarter : 4
month :  12 quarter : 4

Upvotes: 2

Related Questions