Discussion Board for collaboration on QlikView Scripting.
I need to find month & days between 2 dates.
Well i tried like this:
div(date2-date1, 30) as months
(date2-date1)-div(date2-date1, 30)*30 as days
this is give me some months & days.
But i like to know is there any other better solution of this?
Interval ( date2 - date1, 'mm' ) for months
Interval ( date2 - date1, 'dd' ) for days
don't know, it's not giving me right result.
interval(date2-date1.'mm') - it's giving me just days.
any other suggestion?
SubField(Interval(date2 - date1, 'mm-dd'), '-', 1)
I suggest to split this problem into two steps:
1. Create a calendar
2. Count days and months based on the load statement, like this:
COUNT(DATE) AS DAYS,
COUNT(DISTINCT MONTH) AS MONTHS
(DATE >= '$(dateStart)') AND
(DATE <= '$(dateEnd)')
"dateStart","dateEnd" - variables.
This will give you exactly what you need.