Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
yanivbm88
Creator
Creator

Set work week in 'Lastworkdate' function

I am using the lastworkdate function, which should return the date once adding x working days to the starting date, for example:

  • lastworkdate ('2007-02-19', 9) returns '2007-03-01'


How would you set which weekdays should be referred as working days?

I understood that the default is Monday-Friday, but how can I change it to Sunday-Thursday?

I tried modifying FirstWeekDay attribute with no success

1 Solution

Accepted Solutions
yanivbm88
Creator
Creator
Author

Actually, deducting one day from LASTWORKDATE output and adding one day to starting date will give the desired output.

lastworkdate (START_DATE+1, DAYS_AMOUNT)-1

View solution in original post

6 Replies
martinpohl
Partner - Master
Partner - Master

Hello Yaniv,

there are no other options in lastworkdate than holidays.

One solution:

Create your own workingday calendar (e.g, beginning at 1/1/2000 each day get the option working day yes/no, kumulate all days until 12/21/2020 (for example could be working day 2,219)

Than apply to each date the working day and apply again the lowest date to this day so you will get the last working day.

Regards

dan_sullivan
Creator II
Creator II

SET FirstWeekDay=5   // this will set Saturday as the first day of the week in your script declarations

Then you can use WEEKEND formula to always get the Friday date.

WEEKEND('2007-02-19') should return the friday you are looking for

dan_sullivan
Creator II
Creator II

Did this work you?  Please update the thread if it did.

yanivbm88
Creator
Creator
Author

What I requested was to add X amount of working days to a certain date (as in LASTWORKDATE formula), based on Sunday-Thursday work-week,  .

I assume this is not possible with LASTWORKDATE, based on the comment of martinpohl‌.

yanivbm88
Creator
Creator
Author

Hi Martin,

This can be a solution, but isn't there any built-in formula that allows working-week modification?

yanivbm88
Creator
Creator
Author

Actually, deducting one day from LASTWORKDATE output and adding one day to starting date will give the desired output.

lastworkdate (START_DATE+1, DAYS_AMOUNT)-1