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

Button to change the day of a calendar picker

Hello I have a date picker with two button, one button to move forward one day and the other to move back a day but I can't do a good function to make it work, I have set two var for the two button  true to move foward and false to move back and i've put this in my date picker default date 

 

Switch(varThisDay;
true; Date(Year(Today());Month(Today());Day(Today()));
false; DateAdd(Date(Year(Today());Month(Today());Day(Today())); -1; Days))

 

but It don't work like I want, for exemple today is the 17 but when I click and the button to move foward it does nothing because it is set to go at today and the button to move back just move back one day and dont move back again if I want to go at the day 15

and I don't find how to maki this work

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Dive1 

Set the OnSelect of your forward button to:

    UpdateContext({lclDate: DateAdd(Coalesce(lclDate, Today()), 1)})

Set the OnSelect of your backward button to:

    UpdateContext({lclDate: DateAdd(Coalesce(lclDate, Today()), -1)})

Then set the DefaultDate on your date chooser to:

    Coalesce(lclDate, Today())

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

2 REPLIES 2
RandyHayes
Super User
Super User

@Dive1 

Set the OnSelect of your forward button to:

    UpdateContext({lclDate: DateAdd(Coalesce(lclDate, Today()), 1)})

Set the OnSelect of your backward button to:

    UpdateContext({lclDate: DateAdd(Coalesce(lclDate, Today()), -1)})

Then set the DefaultDate on your date chooser to:

    Coalesce(lclDate, Today())

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Thank you it works

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.

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 (4,309)