Brian Dunning's FileMaker Custom Functions

cf_cwSort ( dat ; sep ; start )

Shows from a date the calendas week in the form yy (separator) cw ... With the right year!

  Be the first to rate this function Log in to vote

Fabrice Ricker   Fabrice Ricker - Show more from this author
Kultur und Computer
http://www.kultur-und-computer.de

Share on Facebook Share on Twitter

  Sample input:
cf_cwSort ( "2018.01.03" ; "|" ; "2" )
  Sample output:
19|01

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

/*
################################################################################

___ Function name: cf_cwSort ( dat ; sep ; start )
___ Version: 1.0 --- January 3. 2019
___ Code language: English
___ FMP version: since 7
___ Written on January 3. 2019
___ Author: Fabrice Ricker
___ Contact: fabrice.ricker@kultur-und-computer.de

Description:
Shows from a date the year and the calendar week (January 3. 2019 => 19|01 … With „|“ as separator)
But … Not the year of the date, but of the CW!

Example:
In Europe, the CW begins at Monday, so the 31.12.2018 will shows correctly 19|01, and not 18|01!

1.0: I‘m not sure, if it is 100% safe >;-)

Parameters:
(dat) Any date

(sep) Everything you need, if you want to separate the two values

(start) startingDay for the WeekOfYearFiscal, any number between 1 and 7, where 1 represents Sunday … Exactly the same as the FileMaker function needs

~diff is the amount of days needed to get the date of the last day of the „fiscal“ calendar week, that it self is needed to get the right year associated to this calendar week!

################################################################################
*/

Let ( [
~dow = DayOfWeek ( dat ) ;
~diff = 6 -Mod ( ~dow +7 -start ; 7 ) ;
~lastday = dat + ~diff ;

~woyf = WeekOfYearFiscal ( dat ; start ) ;

~yy = Right ( Year ( ~lastday ) ; 2 ) ;
~cw = Right ( "0" & ~woyf ; 2 )
] ;

~yy & sep & ~cw

)

//###############################################################################

 

Comments

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 15 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: