Brian Dunning's FileMaker Custom Functions

MagicDates ( range )

Gives you FM-Find Friendly date ranges based on User-Friendly input. Works great with the

  Average rating: 4.3 (36 votes) Log in to vote

Andy Frazier   Andy Frazier - Show more from this author
Mx4Px
http://www.andyfrazier.net

Share on Facebook Share on Twitter

  Sample input:
MagicDates("LastQuarter")
  Sample output:
4/1/2007...6/30/2007

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Available ranges:
Today
Yesterday
Tomorrow
ThisWeek
LastWeek
NextWeek
ThisMonth
LastMonth
NextMonth
ThisYTD
LastYTD
NextYTD
ThisYear
LastYear
NextYear
ThisQuarter
LastQuarter
NextQuarter

**Special thanks to Excelisys & the "Business Tracker" for the brilliantly simple way of calculating quarters.

 

Comments

Hal   Hal, Aiken, SC
Jun 10, 2010
Very handy function!
 
Doug Larsen   Doug Larsen, Mpls, MN
Sep 15, 2010
A very handy function but be aware that the parameter called ThisQuarter actually returns a date range that that would more accurately be called QuarterToDate.

For instance, if it is 8/15/2010 and you run the function using parameter "ThisQuarter" you would likely expect it to return:

7/1/2010...9/30/2010

But it actually returns:

7/1/2010...8/15/2010

PS. I couldn't find an email address for the author so he is unaware of the problem.
 
Lazarus Sismanis   Lazarus Sismanis, Decision Group
Jun 17, 2021
@Doug Larsen: Good observation, regarding 'ThisQuarter". For those that need help in addressing this, you can replace the (entire) line for: "range="ThisQuarter" " with the following lines to create selections for "ThisQuarter" and "ThisQuarterToDate"

range="ThisQuarter"; Let ( xMod = Case ( Mod ( Month ( Get ( CurrentDate ) ) ; 3 ) = 0 ; 3; Mod ( Month ( Get ( CurrentDate ) ) ; 3 ) ) ;
Date ( Month ( Get ( CurrentDate ) ) - xMod + 1; 1 ; Year ( Get ( CurrentDate ) ) ) &"..."& Date ( Month ( Get ( CurrentDate ) ) + 1 ; 1 ; Year ( Get ( CurrentDate ) ) ) - 1);
range="ThisQuarterToDate";Let ( xMod = Case ( Mod ( Month ( Get ( CurrentDate ) ) ; 3 ) = 0 ; 3; Mod ( Month ( Get ( CurrentDate ) ) ; 3 ) ) ;
Date ( Month ( Get ( CurrentDate ) ) - xMod + 1; 1 ; Year ( Get ( CurrentDate ) ) ) &"..."&Get(CurrentDate));
 

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 20 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth: