Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
mohammadkhatimi
Partner - Specialist
Partner - Specialist

Count of Saturday in whole month

For Example,

April 2016 has 30 days and 5 Saturdays.

I want to count only those 5 Saturdays,even if they aren't passed.

For instance today is(4th Apr 2016) Still the count should be 5 Saturdays.

This should work for every month.

Regards,

Mohammad

1 Solution

Accepted Solutions
swuehl
MVP
MVP

You can use something like

=Div(WEEKDAY(StartDate-6)+1-StartDate+EndDate,7)

=Div(WEEKDAY(Monthstart(today())-6)+1-Monthstart(today())+Floor(MonthEnd(today())),7)

to count the number of saturdays in a date range (StartDate, EndDate)

Or use a master calendar with added Weekday Count data, like indicated above (but maybe with additional monthly aggregations).

View solution in original post

15 Replies
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

You can create a flag.

Load if(WeekDay(Date) = 'Sat',1,0) as SatFlag

From xyz;

and then use the Sum(SatFlag) in chart.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
sunny_talwar

Are you wanting to do this in the script or the front end?

swuehl
MVP
MVP

You can use something like

=Div(WEEKDAY(StartDate-6)+1-StartDate+EndDate,7)

=Div(WEEKDAY(Monthstart(today())-6)+1-Monthstart(today())+Floor(MonthEnd(today())),7)

to count the number of saturdays in a date range (StartDate, EndDate)

Or use a master calendar with added Weekday Count data, like indicated above (but maybe with additional monthly aggregations).

mohammadkhatimi
Partner - Specialist
Partner - Specialist
Author

@Sunny in frontend...

I want Count of Satudary is 5...

avinashelite

Try like this

Sum(If(weekDay(date_field)='Sat',1,0))

mohammadkhatimi
Partner - Specialist
Partner - Specialist
Author

sunindia

Please help me with this issue.

swuehl
MVP
MVP

I'm not Sunny, but have you tried my expressions I've suggested above?

sunny_talwar

I would seriously suggest you to try Stefan's provided solution. More often then not his solutions are the best you will find on the community. So I urge you to not disregard his responses.

If it still doesn't work, then I don't mind chipping in, but I doubt that's going to happen

Not applicable

Hi Mohammad

If you want to calculate the number of Saturdays in a month(April), it all depends on if you have data for the rest of the month (ie. after the 4th Apr 2016).


The formula - 'Sum(If(weekDay(date_field)='Sat',1,0))' will work but, if you only have data up until the 4th Apr 2016 then the answer will be 1, if you have data for the whole of April 2016 it will be 5