Function for Fiscal Week Numbering

Ideas for new features & functions

Moderators: Dorian (MJT support), JRL

Post Reply
Franklin
Newbie
Posts: 16
Joined: Mon Dec 14, 2015 5:14 pm

Function for Fiscal Week Numbering

Post by Franklin » Tue Jul 21, 2020 11:20 pm

Function 1: Function which determines Fiscal Week number of a given year
Function 2: Get the correct Week number of a given Date (use after Function 1 is available)

Function 1: Suggest a function which returns the fiscal year week number.

Fiscal year starts differently for everyone which is a reason for value.

Function 1 syntax should include considerations for the following:

1. Which year. This is necessary to determine leap years
2. Start month of Fiscal Year
3. Which day of the week does the week begin? I.e. Sunday, Monday, etc.


Resources:
ISO 8601 sets a standard for numbering weeks in a year.

Stack OverFlow has a jump point for C# code
https://stackoverflow.com/questions/111 ... given-date

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1347
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Function for Fiscal Week Numbering

Post by Dorian (MJT support) » Wed Jul 22, 2020 7:28 am

I'd imagine this can be achieved with DateDiff, if I understand correctly.
Yes, we have a Custom Scripting Service. Message me or go here

User avatar
Dorian (MJT support)
Automation Wizard
Posts: 1347
Joined: Sun Nov 03, 2002 3:19 am
Contact:

Re: Function for Fiscal Week Numbering

Post by Dorian (MJT support) » Wed Jul 22, 2020 9:55 am

Something along these lines should be enough to get you started :

Code: Select all

//Get Today's date
GetDate>today

//Set the year start
Let>YearStart=2020-04-23

//How many weeks have elapsed?
Datediff>today,YearStart,W,WeekNumber
MDL>Week Number %WeekNumber%

//What day of the week was the year start. Credit : JRL.
VBEval>WeekdayName(Weekday("%YearStart%",0)),vDayoftheWeek
MDL>%YearStart% was a %vDayoftheWeek%
Yes, we have a Custom Scripting Service. Message me or go here

Franklin
Newbie
Posts: 16
Joined: Mon Dec 14, 2015 5:14 pm

Re: Function for Fiscal Week Numbering

Post by Franklin » Thu Jul 23, 2020 10:13 pm

Thought I'd share this: If its posted in the wrong place, I can repost in the tech scripts

Special Thanks to Dorian for the direction and code

Code: Select all

//Get Today's Date
getDate>Today

//Get Current Year
Year>FYear

//Add One Year for current FY ---
DateAdd>Today,Y,1,FY2

//Grab Just the Year Part
DatePart>%FY2%,Y,FY3

//Grab Last Two digits of four digit year
MidStr>%FY3%,3,2,FY

//
//Uncomment line below for Modal to display FY result
//MDL>Year is %FY%  Week is %WK%
//
//Set FY Year Start
Let>FYearStart=2020-07-01

//How Many Weeks have lapsed?
DateDiff>Today,FYearStart,W,WK

Variable WK returns the week
Variable FY returns last two digits of the year

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts