Month # of each Calendar Quarter

I m trying to determine the current month number of each quarter via AppleScript.

Depending on the month number returned the script will begin populating data in a spreadsheet on a different line.

1st Quater
If Jan then month number would be 1
If Fab then month number would be 2
If Mar then month number would be 3

2nd Quater
If April then month number would be 1
If May then month number would be 2
If Jun then month number would be 3

3rd Quarter
If July then month number would be 1
If Aug then month number would be 2
If Sep then month number would be 3

4th Quarter
If Oct then month number would be 1
If Nov then month number would be 2
If Dec then month number would be 3

If month number is 1 then continue script in cell D3
If month number is 2 then continue script in cell D4
If month number is 3 then continue script in cell D5

What are your months? Text? AppleScript month constants? If the latter, you can calculate the number like this:

((May as integer) - 1) mod 3 + 1
--> 2

Thank you, the month will be determined by the current date, important piece of information… :). Is there a better way to write this?

set now to (current date)
set current_month to (month of (now) as number)
((current_month as integer) - 1) mod 3 + 1
--> 1

(month of (current date)) mod 3 + 1
((month of (current date)) - 1) mod 3 + 1 -- Automatic coercion

Or:

(((month of (current date)) as integer) - 1) mod 3 + 1 -- Explicit coercion

:slight_smile:

Thank you both.