Brian Dunning's FileMaker Custom Functions

DateOfWeek ( week ; yearOfWeek ; type )

Calculate the first date of a given week and year

  Average rating: 4.0 (42 votes) Log in to vote

Reinder Wolting   Reinder Wolting
ABECON
http://www.abecon.nl

Share on Facebook Share on Twitter

  Sample input:
DateOfWeek ( 1 , 2009 , 1 )
  Sample output:
29-12-2008

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

When you only have the week number and a year and you need to know a date in that week, this function calculates the date of the first day of that week. It also takes in account the prefered starting day.

 

Comments

Mark Rubenste   Mark Rubenste, Evanston, IL
Dec 29, 2014
This CF worked for week 1 last year (2014), but is one week off this year (2015). I think the the last line of code should be this:
xFirstYearDate + ( ( week - If ( xFirstWeekDay > 6 ; 0 ; 1 ) ) * 7 ) - xFirstWeekDay + 1

NOT this:
xFirstYearDate + ( ( week - If ( xFirstWeekDay > 4 ; 0 ; 1 ) ) * 7 ) - xFirstWeekDay + 1

In other words, > 4 should be > 6.

Am I correct?
 

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: