Discussion board where members can get started with QlikView.
I have to calculate date difference between two dates but I have to exclude
"saturday" and "sunday".
For example: '2012-09-14' - '2012-09-07' = 7
but it should give me 5 as it is included saturday and sunday.
Please advise how to achieve it.
It returns 6 because, as I mentioned above, it counts both dates specfied as parameters so the calculation is as follows:
2012-09-07 (Friday) = 1 +
2012-09-14 (Friday) = 5
Therefore the total 6 days, including both dates and excluding 2012-09-08 (Saturday) and 2012-09-09 (Sunday).
Hope that helps.
View solution in original post
Use the function NetWorkDays(), that returns the number of monday to friday excluding saturdays and sundays from the dates speficied, including both:
hello you can use
networkdays ( '2007-02-19', '2007-03-01' ) is 9
networkdays ( '2006-12-18', '2006-12-31', '2006-12-18', '2006-12-18' ) is 8
holidays be passed as string
It is giving me 6 days it should be 5 days.
It is only excluding sunday I guess.
You can always take a paper calendar, marker and see that it's not so hard to write such expression.
Keep in mind that QV has useful functions div() and mod().
In this case you can count any number of days in a week.