Brian Dunning's FileMaker Custom Functions

WeekStartingMONDAY ( xDate )

Returns the date of Monday for any date within the week.

  Average rating: 4.1 (29 votes) Log in to vote

Tony Tanevski   Tony Tanevski - Show more from this author
Hi-Voltage
http://www.hi-voltage.com.au

Share on Facebook Share on Twitter

  Sample input:
WeekStartingMONDAY ( 01/06/2006 )
  Sample output:
01/02/2006

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

Returns the date of Monday for any date within the week.

For example, if today is Friday, what was the date at the start of this week (Monday).

Useful for reporting or calendars.

 

Comments

Sean   Sean, Private
Feb 2, 2010
I think you almost had it but there is no reason for the let or case statement. This is simpler.

GetAsDate ( field ) - DayOfWeek ( field ) +2

Or use +1 instead of +2 to get Sunday instead of Monday. Personally I call it weekStart and add +1 in the function and add another +1 in the calculation when I call the weekStart function. There really is no need to have a weekStart and a weekStartMonday.
 
Patrick Neame   Patrick Neame, Ironbridge
Jun 3, 2011
Of course you can use

GetAsDate ( EndDate ) - DayOfWeek ( EndDate ) +6

To correct data entry errors if you want the end date to be on a Friday. Thus when dealing with a working week (mon - fri) the +2 function can modify the start date to correct any errors to Monday and +6 to Friday. Be aware that if the EndDate has been entered as Sunday that will flip the end date correction through to the end of the following week.
 

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: