Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for
Did you mean:
Anonymous
Not applicable

## FinYearWeek Calculations

Hi All,

How can you calculate the Financial Year and Week number from a date.

For example:

All information I have is a date column which contains dates in the format 'YYYY/MM/DD'.

The requirement is that I get the Financial Year and the week number as a code.

Week(Date) provides the week of the year.

Year(Addmonths(Date),12) will provide me with the financial year.

However, using the below does not yield the correct result:

My Financial Year starts in July of the year.

Qlikview starts the week on a Saturday to Friday period, and that is not correct, my weeks need to start on a monday and finish on a sunday.

My variables are set up as below:

SET MonthNames='Jan;Feb;Mar;Apr;May;Jun;Jul;Aug;Sep;Oct;Nov;Dec';

SET DayNames='Mon;Tue;Wed;Thu;Fri;Sat;Sun';

4 Replies

Can you set in your variable environment like

SET FirstWeekDay=2; // 1 Starts from Sunday.

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
MVP

Hi Ruan,

Have a look at the blogs below by Henric Cronstrom hic which detail how to setup calendars for Financial Year & Weeks starting at different months.

Redefining the Week Start

Redefining the Week Numbers

Are you doing this in script if so, this works as From Date we need to go back 180 Days that means we need to calculate how many dates week has. So, 180 / 7 = 25. If Today() it returns 39 - 25 = 13. And output returns here 2017/13 so from this we are picking Right side of 2 strings and it should return 13 as always..

HTH

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable
Author

Solved this by using the below formula,

For any future enquiries, bare in mind that our financial year period starts in july.  And we work on a Mon-Sun Period.  The formula should just be adjusted accordingly.