web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / count of no of working...
Power Apps
Unanswered

count of no of working days

(0) ShareShare
ReportReport
Posted on by

i have used below code to count no of working days based on datepicker1 but when i select feb month showing wrong data .how to fix this?
With(
{
varDateRange: ForAll(
Sequence(31,1),
Text(Month(DataCardValue4.SelectedDate) & "/" & Value & "/" & Year(DataCardValue4.SelectedDate),"DD/MM/YYYY")
)
},
// show only dates Monday to Friday and exclude holidays
CountIf(
varDateRange,
And(
Weekday(Value,StartOfWeek.Sunday) in [2, 3, 4, 5, 6],
Not(Value in Col_Holidaylist.Date1)
)
)
)

Categories:
I have the same question (0)
  • Rajkumar_M Profile Picture
    3,747 Moderator on at

    Hi

    The issue with the formula you provided for counting the number of working days based on the selected date is that it assumes that February has 31 days. To fix this issue, you can modify the formula to use the Days function to get the number of days in the selected month. 

     

    With( 
    { varDateRange:

    ForAll( Sequence(Days(DataCardValue4.SelectedDate), 1),
    Text(Value & "/" & Month(DataCardValue4.SelectedDate) & "/" &
    Year(DataCardValue4.SelectedDate), "DD/MM/YYYY") ) },

    // show only dates Monday to Friday and exclude holidays

    CountIf( varDateRange, And( Weekday(Value, StartOfWeek.Sunday) in [2, 3, 4, 5, 6],
    Not(Value in Col_Holidaylist.Date1) ) ) )
     

     

    Thanks!

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

     

     

  • venky232 Profile Picture
    on at

    not working code sequence as some invalid arguments

  • Rajkumar_M Profile Picture
    3,747 Moderator on at

    Try this

    With(
    {
    varStartDate: Date(Year(DataCardValue4.SelectedDate), Month(DataCardValue4.SelectedDate), 1),
    varEndDate: Date(Year(DataCardValue4.SelectedDate), Month(DataCardValue4.SelectedDate) + 1, 1),
    varDateRange: Filter(
    AddColumns(
    Sequence(Days(varEndDate - varStartDate), 0),
    "Date",
    DateAdd(varStartDate, Value, Days(1))
    ),
    Not(DateAdd(varStartDate, Value, Days(1)) in Col_Holidaylist.Date1) &&
    Weekday(DateAdd(varStartDate, Value, Days(1)), StartOfWeek.Sunday) in [2, 3, 4, 5, 6]
    )
    },
    CountRows(varDateRange)
    )

  • venky232 Profile Picture
    on at

    error sequence as invalid arguments
    Days is unknown or unsupported function

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 534

#2
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 306

Last 30 days Overall leaderboard