WeekFiscalToDate ( )

Function stats

Average user rating
391
348
9999
Support
FileMaker 7.0 +
Date posted
25 February 2013
Last updated
25 February 2013
Version
Recursive function
No

Author Info
 menno

4 functions

Average Rating 5.0

author_avatar



 

Function overview

Prototype

WeekFiscalToDate  ( Yearnr;   WeeknrOfYear;   Firstweekday )


Parameters

Yearnr  between 1 and 4000


WeeknrOfYear  any natural number, limited only by the resulting date


Firstweekday  1…7 (representing sunday…saturday)


Description

Tags:  Date  

This function works more or less as the inverse function of WeekOfYearFiscal(), which is built into Filemaker. Only instead of calculating the weeknumber, it calculates the date for the given day of the given weeknr.

The function can also be used to calculate a particular occurrence of a day in a given month:
WeekFiscalToDate ( Year ; WeekOfYearFiscal ( Date ( Month ; 7 * occurrence ; Year ) ; Firstweekday ) ; Firstweekday )
example: You'd like to calculate the 3rd occurrence of thursday in april:
WeekFiscalToDate ( 2013 ; WeekOfYearFiscal ( Date ( 4 ; 7 * 3 ; 2013 ) ; 5 ) ; 5 ) which would result into 4/18/2013
for 2014: 4/17/2014
for 2015: 4/16/2015
for 2016: 4/21/2016

Examples

Sample input

WeekFiscalToDate ( 2013 ; 5 ; 2 )
WeekFiscalToDate ( 2015 ; 5 ; 1 )
WeekFiscalToDate ( 2015 ; 5 ; 2 )


Sample output

1/28/2013
2/1/2015
1/26/2015

 

Function code

// #####################################################
// ## WeekFiscalToDate function
// ## Author:
// ## Menno van Beek - STB Automatisering & Advies BV -
// ## Houten, the Netherlands
// ##
// ## Format:
// ## WeekFiscalToDate ( Yearnr ; WeeknrOfYear ; Firstweekday )
// ##
// ## Parameters:
// ## Yearnr = between 1 and 4000
// ## WeeknrOfYear = any natural number, limited only by
// ## the resulting date
// ## Firstweekday = 1…7 (sunday…saturday)
// ##
// ## Data type returned:
// ## Date calculated from the given fiscal weeknumber in the
// ## given year at the given Firstweekday
// ##
// ## Description:
// ## This function works more or less as the inverse function of
// ## WeekOfYearFiscal(), which is built into Filemaker. Only
// ## instead of calculating the weeknumber, it calculated the date
// ## for the given day of the given weeknr.
// ##
// ## Other use:
// ## You can also use this function to calculate a particular
// ## occurrence of a day in a given month:
// ## WeekFiscalToDate ( Year ;
// ## WeekOfYearFiscal (
// ## Date ( Month ; 7 * occurrence ; Year ) ;
// ## Firstweekday ) ;
// ## Firstweekday )
// ##
// ## February 24, 2013
// ####################################################
Let( [
Dd1Yr = Date ( 1 ; 1 ; Yearnr ) ;
// ## january 1st
Dy1Wk1 = DayOfWeek ( Dd1Yr - Firstweekday ) ;
// 1st day of week of january 1st
WeekOfYear1 = WeekOfYearFiscal ( Dd1Yr ; Firstweekday ) ;
// ## weeknr of january 1st
Dd1Wk1 = Dd1Yr - Dy1Wk1 +
If ( WeekOfYear1 > 1 or Dy1Wk1 = 7 ; 7 )
// ## date of 1st day of weeknr 1 of year
] ;
Dd1Wk1 + ( WeeknrOfYear - 1 ) * 7
// ## the result as date
)

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/348

    Prototype: WeekFiscalToDate( Yearnr; WeeknrOfYear; Firstweekday )
    Function Author: menno (http://www.fmfunctions.com/mid/391)
    Last updated: 25 February 2013
    Version: 1.1

*/
// ===================================

 

 

 

 

 

 

 

Top Tags

Text Parsing  (33)
List  (32)
Date  (28)
XML  (27)
Format  (23)
Sql  (22)
Dev  (20)
Debug  (17)
Interface  (15)
Layout  (15)
Text  (14)
Variables  (13)
Filter  (12)
Layout Objects  (11)
Design  (10)
Array  (8)