cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Jean_9681
Helper III
Helper III

Power Apps Calendar Component - How to Disable/block Weekends & past/back dates

I am using the PowerApps OOTB Calendar Screen components to select multiple dates/days and i am trying to  disable the past/back dates and weekends so users cannot select back dates so far i was able to disable just one day of the week by setting 
 the Display Mode of Title4/label in the gallery to 

 

 

If(Weekday(DateAdd(_firstDayInView, ThisItem.Value, Days))=7,DisplayMode.Disabled,DisplayMode.Edit)

 



 & set the Disabled Fill Property to 

 

 

If(Weekday(DateAdd(_firstDayInView,ThisItem.Value, Days))=7,LightGray)

 



2022-09-12_12h24_22.jpg

 
 


Need some help with the correct formula to disable (Sunday and past dates)..

Thank you for your time..



 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
EricBLott
Resolver III
Resolver III

DisplayMode property:

With(
    {
        calendarDate: DateAdd(
            _firstDayInView,
            ThisItem.Value,
            Days
        )
    },
    If(
        Or(
            calendarDate < Today(),
            Weekday(calendarDate) in [1,7]
        ),
        Disable,
        DisplayMode.Edit
    )
)

Fill Property:

With(
    {
        calendarDate: DateAdd(
            _firstDayInView,
            ThisItem.Value,
            Days
        )
    },
/*Fill value changes if the gallery item day = today, or if it lies outside of the current month*/             
If(
    calendarDate < Today(),RGBA(200, 200, 200, 0.3),
    /*Date selected is today*/
    calendarDate = Today() && calendarDate = _dateSelected, RGBA(0,0,0,0),
    /*Today when it is not selected*/
    calendarDate = Today(), ColorFade(Subcircle1.Fill, 0.67), 
    /*The day is outside the range of the currently selected month*/
    Abs(Self.Text - ThisItem.Value) > 10,RGBA(200, 200, 200, 0.3), RGBA(0, 0, 0, 0)))

You can set DisabledFill back to RGBA(0, 0, 0, 0)

 

View solution in original post

EricBLott
Resolver III
Resolver III

Correction, the Fill property needs to be set to this:

With(
    {
        calendarDate: DateAdd(
            _firstDayInView,
            ThisItem.Value,
            Days
        )
    },
/*Fill value changes if the gallery item day = today, or if it lies outside of the current month*/             
If(
    Or(calendarDate < Today(),Weekday(calendarDate) in [1,7]),RGBA(200, 200, 200, 0.3),
    /*Date selected is today*/
    calendarDate = Today() && calendarDate = _dateSelected, RGBA(0,0,0,0),
    /*Today when it is not selected*/
    calendarDate = Today(), ColorFade(Subcircle1.Fill, 0.67), 
    /*The day is outside the range of the currently selected month*/
    Abs(Self.Text - ThisItem.Value) > 10,RGBA(200, 200, 200, 0.3), RGBA(0, 0, 0, 0)))

View solution in original post

7 REPLIES 7
EricBLott
Resolver III
Resolver III

DisplayMode property:

With(
    {
        calendarDate: DateAdd(
            _firstDayInView,
            ThisItem.Value,
            Days
        )
    },
    If(
        Or(
            calendarDate < Today(),
            Weekday(calendarDate) in [1,7]
        ),
        Disable,
        DisplayMode.Edit
    )
)

Fill Property:

With(
    {
        calendarDate: DateAdd(
            _firstDayInView,
            ThisItem.Value,
            Days
        )
    },
/*Fill value changes if the gallery item day = today, or if it lies outside of the current month*/             
If(
    calendarDate < Today(),RGBA(200, 200, 200, 0.3),
    /*Date selected is today*/
    calendarDate = Today() && calendarDate = _dateSelected, RGBA(0,0,0,0),
    /*Today when it is not selected*/
    calendarDate = Today(), ColorFade(Subcircle1.Fill, 0.67), 
    /*The day is outside the range of the currently selected month*/
    Abs(Self.Text - ThisItem.Value) > 10,RGBA(200, 200, 200, 0.3), RGBA(0, 0, 0, 0)))

You can set DisabledFill back to RGBA(0, 0, 0, 0)

 

EricBLott
Resolver III
Resolver III

Correction, the Fill property needs to be set to this:

With(
    {
        calendarDate: DateAdd(
            _firstDayInView,
            ThisItem.Value,
            Days
        )
    },
/*Fill value changes if the gallery item day = today, or if it lies outside of the current month*/             
If(
    Or(calendarDate < Today(),Weekday(calendarDate) in [1,7]),RGBA(200, 200, 200, 0.3),
    /*Date selected is today*/
    calendarDate = Today() && calendarDate = _dateSelected, RGBA(0,0,0,0),
    /*Today when it is not selected*/
    calendarDate = Today(), ColorFade(Subcircle1.Fill, 0.67), 
    /*The day is outside the range of the currently selected month*/
    Abs(Self.Text - ThisItem.Value) > 10,RGBA(200, 200, 200, 0.3), RGBA(0, 0, 0, 0)))
Jean_9681
Helper III
Helper III

@EricBLott Thank you so much, this is exactly what i was trying to achieve.. 

Jean_9681
Helper III
Helper III

@EricBLott  The solution works perfect for the background color fill, however the users can still click/select the weekends and past days 
i was hoping to disable past days and weekends 😞 

@Jean_9681 Even after setting the DisplayMode property of the calendar gallery item to the formula I pasted? It's working on my end. 

**I noticed a typo in my formula. Try this one for DisplayMode 

With(

    {

        calendarDate: DateAdd(

            _firstDayInView,

            ThisItem.Value,

            Days

        )

    },

    If(

        Or(

            calendarDate < Today(),

            Weekday(calendarDate) in [1,7]

        ),

        Disabled,

        DisplayMode.Edit

    )

)

Jean_9681
Helper III
Helper III

Thanks @EricBLott it works now.. 

Nagarajan1
New Member

_firstDayInView isn't recognized, can you help me please

2023-01-19_15-59-22.jpg

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,752)