Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
fbi
Contributor III
Contributor III

Networkdays with RangeMin

Hi, I'm trying to calculate the number of working days between a date and another date calculated using RangeMin since it will choose the lowest date between several as follows:

Workingdays(Date1, RangeMin(date2, date3, date4)) 

but it doesn't work

thanks in advance for all your help

1 Solution

Accepted Solutions
Or
MVP
MVP

If your fields were already dates to begin with, then you shouldn't need to do anything special (though it's recommended to apply date(Field) anyway).

If your fields were previously strings or numbers, then you would have to explicitly convert them to dates first. Are your fields currently strings / numbers with the specific format 'YYMMDD' (e.g. 210825)? They would have to be that for your date#() function to work correctly with that syntax.

View solution in original post

7 Replies
Or
MVP
MVP

This works correctly near as I can tell.

Load Today()-10 as StartDate, Today() as Date1, Today()-1 as Date2, Today()+1 as Date3
Autogenerate(1);

NetWorkDays(StartDate,RangeMin(Date1, Date2, Date3)) returns 6 (right now, obviously that will shift depending on what day of the week we're on).

fbi
Contributor III
Contributor III
Author

I wrote exactly the same but it doesn't work it returns 0 as result for all the lines

Or
MVP
MVP

I'd suggest checking that your values all evaluate to valid dates, then. The issue isn't with the formula itself, it's with something going on with your data, since using the same formula on generic data works correctly.

fbi
Contributor III
Contributor III
Author

I guess I have to declare the fields as date in some way.

In the script I wrote as follows:

Date(Date#([LADATU], 'YYMMDD'), 'YYYY-MM-DD')

and the same with all the other date fields

Or
MVP
MVP

If your fields were already dates to begin with, then you shouldn't need to do anything special (though it's recommended to apply date(Field) anyway).

If your fields were previously strings or numbers, then you would have to explicitly convert them to dates first. Are your fields currently strings / numbers with the specific format 'YYMMDD' (e.g. 210825)? They would have to be that for your date#() function to work correctly with that syntax.

fbi
Contributor III
Contributor III
Author

now it works! thank you very much for your help, high appreciated!

Or
MVP
MVP

Sure thing. If possible, could you post what the exact solution was and mark the question solved so others might be able to use it in the future?