Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count of days between two dates

Hi All,

I want to know the count of number of days between two dates.

The dates are calculate in the form of two variables vPeriodFrom and vPeriodTo.

For example If vPeriodFrom is 01012015 and vPeriodTo is 28022015

The count of days should be 59.

How can i calculate this. Please help.

5 Replies
Not applicable
Author

well, if you have real date (or num(date)) format in your valiables, it will be simple:

=vPeriodTo - vPeriodFrom + 1

if you have exactly what you'he written, you first need to make this variables become real dates, so qlik will understand them:

= MakeDate(right(vPeriodTo, 4), left(right(vPeriodTo, 6), 2), left(vPeriodTo, 2))

- MakeDate(right(vPeriodFrom, 4), left(right(vPeriodFrom, 6), 2), left(vPeriodFrom, 2)) + 1

sunny_talwar

Or you can try this also (if it isn't date format)

Num(Date#(vPeriodTo, 'DDMMYYYY') - Num(Date#(vPeriodFrom, 'DDMMYYYY')) + 1

Gabriel
Partner - Specialist III
Partner - Specialist III

Hi,

How about using NetWorkDays function

NetworkDays($(vPeriodFrom) , $(vPeriodTo), {, holiday})


sunny_talwar

Well networkday will exclude weekends and the count of days will be less than 59. He needs to count all the days, so networkday won't work here.

maxgro
MVP
MVP

replace with your variables

=date#('28022015', 'DDMMYYY') - date#('01012015', 'DDMMYYY')  +1

1.png