Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Calendar Screen - First day of week Saturday and visibility issues

Posted on by
I have managed to edit the Calendar Screen to have the week start on a Saturday (Rail Weeks run Sat to Fri) and hide any days not in that month. However, for some reason when the first of the month falls on a Saturday it still invisibly displays the entire proceeding week dropping the whole calendar down a row which looks extremely odd. 
 
Anyone got a solution for this? I can see it is to do with this piece of code, where if the first day of the month is the Saturday then the weekday becomes 7 and subtracted. But can't figure out how to change it to suit.
 
/*changes month view to next month*/
Set(_firstDayOfMonth, DateAdd(_firstDayOfMonth, 1, TimeUnit.Months));
Set(_firstDayInView, DateAdd(_firstDayOfMonth, -(Weekday(_firstDayOfMonth)), TimeUnit.Days));

 
This is what it looks like when the first of the month is any other day of the week:
 
 
And this is what it looks like when it falls on the Saturday:
 
Categories:
  • Suggested answer
    SaiRT14 Profile Picture
    SaiRT14 1,334 on at
    Calendar Screen - First day of week Saturday and visibility issues
    pls try the below:
     
    Use the Weekday function with an optional second parameter to set the week to start on Saturday. This will align the calculations with your desired week structure. Replace Weekday(_firstDayOfMonth) with Weekday(_firstDayOfMonth, StartOfWeek.Saturday).
    Set(_firstDayInView, DateAdd(_firstDayOfMonth, -(Weekday(_firstDayOfMonth, StartOfWeek.Saturday) - 1), TimeUnit.Days));
     
    Ensure that when you navigate between months (next/previous), the logic to calculate _firstDayOfMonth and _firstDayInView remains consistent with this adjustment. Exampel: when moving to the next month: - Set(_firstDayOfMonth, DateAdd(_firstDayOfMonth, 1, TimeUnit.Months));
    Set(_firstDayInView, DateAdd(_firstDayOfMonth, -(Weekday(_firstDayOfMonth, StartOfWeek.Saturday) - 1), TimeUnit.Days));
     
    For the previous month: - Set(_firstDayOfMonth, DateAdd(_firstDayOfMonth, -1, TimeUnit.Months));
    Set(_firstDayInView, DateAdd(_firstDayOfMonth, -(Weekday(_firstDayOfMonth, StartOfWeek.Saturday) - 1), TimeUnit.Days));
     
    this should work, let me know how it goes for you.
     

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,591

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,090

Leaderboard