Brian Dunning's FileMaker Custom Functions

GetPastDate ( dateStart ; monthsNumber )

Find past date 1-12 month/s from a given date - helps construct date ranges

  Average rating: 4.5 (10 votes) Log in to vote

Robert Jackson   Robert Jackson
RJPlus Consulting
https://rjplus.wordpress.com

Share on Facebook Share on Twitter

  Sample input:
GetPastDate ( Get(CurrentDate , 6 )

// UK date format used here
// assuming today = "25/1/2016
  Sample output:
25/07/2015

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

This allows you to get a date - say six months ago. The idea is to help with the construction of date ranges.

dateStart & "..." & GetPastDate (would give a six month date range if monthsNumber = 6)

 

Comments

Lee Smith   Lee Smith
Oct 27, 2016
This will break if Leap Year is involved.
 
Robert Jackson   Robert Jackson, Dundee
Oct 31, 2016
Thanks for looking at this custom function Lee. It seems OK to me - I tested it with leap year options and for other years. Could you give me an example where it breaks - it would be most helpful - ta
 
Tom Fitch   Tom Fitch
Oct 31, 2016
No need to make it that complicated. FileMaker will happily accept a negative month number (or day, but not year) and return the appropriate date. Works for leap years too. Let FileMaker do the math!
E.g.:
Let( now = Get(CurrentDate) ;
Date ( Month ( now ) - 6 ; Day ( now ); Year ( now ) ) )
 
Lee Smith   Lee Smith
Oct 31, 2016
It might be confusing because you and i have a different date structure.
i.e. yours is Day/Month/Year and mine is Month/day/year

If you are going from Mar 29 to Feb (one month) you get March 1st.
 

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.

Under construction. Email me your wish list for improvements.