Announcements
The way to achieve your own success is the willingness to help somebody else. Go for it!
cancel
Showing results for
Did you mean:
Contributor II

## How to count no of Sundays between two dates in qliksense

How to count no of Sundays between two dates in qliksense

Labels (2)

• ### Script

1 Solution

Accepted Solutions

@charu16aug  If you want to do it in backend I am assuming that you have StartDate and EndDate in your data. You can try below

``````let vWeekDayNumber= 6; //0-Mon,1-Tue,2-Wed....
set NoOfSunday = 'Div(num(WeekDay(\$1-(\$(vWeekDayNumber)+1),0))+1-\$1+\$2,7)';

Data:
\$(NoOfSunday(StartDate,EndDate)) as  NoOfSunday
Inline [
StartDate,EndDate
01/03/2023, 01/05/2023
01/04/2023, 01/05/2023 ];``````
9 Replies
Creator

Hi,

You have to create WeekendFlag in your script:

if(WeekDay(yourdatefield)='Sun',1,0) as WeekendFlag

And in your frontend use the below expression

Hope this helps,

help user find answers ! don't forget to mark  a solution that work for you and click the like button!

Contributor II
Author

i have to perform this on backend

Creator

in master calendar.

Then insert

if(WeekDay(yourdatefield)='Sun',1,0) as WeekendFlag,

Contributor II
Author

then how to count no. if Sundays between two dates in the backend?

Creator

In frontend this expression will give you the count of Sundays

Contributor II
Author

this is an intermediate step, so i want to count this in backend only

@charu16aug  If you want to do it in backend I am assuming that you have StartDate and EndDate in your data. You can try below

``````let vWeekDayNumber= 6; //0-Mon,1-Tue,2-Wed....
set NoOfSunday = 'Div(num(WeekDay(\$1-(\$(vWeekDayNumber)+1),0))+1-\$1+\$2,7)';

Data:
\$(NoOfSunday(StartDate,EndDate)) as  NoOfSunday
Inline [
StartDate,EndDate
01/03/2023, 01/05/2023
01/04/2023, 01/05/2023 ];``````
Contributor II
Author

thanks @Kushal_Chawda

MVP

Div(EndDate-StartDate+WeekDay(StartDate)+1,7)

Tags
Community Browser