6 Replies Latest reply on May 2, 2012 2:10 PM by philmodjunk

# Obtaining Quarters Based on Current Date

### Title

Obtaining Quarters Based on Current Date

### Post

Hello,

I'm wondering if I can get the quarter of the based on the current date as well as the previous quarter. I'd like to leave this as an unstored calc so that it updates as needed.

• ###### 1. Re: Obtaining Quarters Based on Current Date

Along the same lines as this, could Filemaker then tell you the date range on the quarters as well?

So as of today, i would have a field that told me it was the 2nd Quarter and another field that told me the date range of 2nd qrt 2012 as 4/1/12...6/30/12"

?

• ###### 2. Re: Obtaining Quarters Based on Current Date

Ceiling ( Month ( Get ( CurrentDate ) ) / 3 )

Will return 1, 2, 3 or 4 for the quarter.

To compute a date range...

Let ( [ Q = Ceiling ( Month ( Get ( CurrentDate ) ) / 3 ) ;
Y = Year ( Get ( CurrentDate ) ) ;
D1 = Date ( Q * 3 - 2 ; 1 ; Y ) ;
D2 = Date ( Q * 3 + 1 ; 0 ; Y )
];
D1 & "..." & D2
)

• ###### 3. Re: Obtaining Quarters Based on Current Date

This worked perfectly to get me the date range of hte current quarter.

Is it possible to show the previous quarter as well? Also, i'm hoping to leave this as an unstored calculation that will keep the showing current and previous quarter. So the beginning of next year, i think that the years might be off since it's scripted to get the year of hte current date.

• ###### 4. Re: Obtaining Quarters Based on Current Date

It's essentially the same calculation:

Let ( [ Q1 = Ceiling ( Month ( Get ( CurrentDate ) ) / 3 - 1 ) ;
Q = If ( Q1 ; Q1 ; 4 ) ;
Y = If ( Q1 ; Year ( Get ( CurrentDate ) ) ; Year ( Get ( CurrentDate ) ) - 1 ) ;
D1 = Date ( Q * 3 - 2 ; 1 ; Y ) ;
D2 = Date ( Q * 3 + 1 ; 0 ; Y )
];
D1 & "..." & D2
)

• ###### 5. Re: Obtaining Quarters Based on Current Date

Wow, Phil...

Never saw that one before...

I would have used mod(month;4) +1 which gives 1,2,3,4

There's more than one way to skin a cat...none of which are safe...

• ###### 6. Re: Obtaining Quarters Based on Current Date

That mod function was rattling around in the back of my mind--used it for years going back to when I was a Comp Sci student writing code in Pascal. Just didn't float to the top until after I'd posted and since it's not really any simpler....

My cat complains loudly no matter which method I use...