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 / DatePicker Change Date...
Power Apps
Answered

DatePicker Change Date Programmatically

(0) ShareShare
ReportReport
Posted on by 32

Hello,

 

I have 2 buttons (next and previous) and a datepicker control.

The datepicker is defaulted to today. 

 

I want te be able to jump to the datepickers next day by clicking next and vice versa.
How do I do this?

Categories:
I have the same question (0)
  • Verified answer
    CarlosFigueira Profile Picture
    Microsoft Employee on at

    You can use a global variable to store the date that is bound to the Default property in the date picker, and in the prev/next buttons you'd decrement/increment the variable value.


    In the app's OnStart property (you can find it on the first screen of your app), you'd need to initialize that value:

    <first screen>.OnStart: Set(defaultDate, Today())

    Now you can add the two buttons (prev/next) and set their properties to update the value of that property:

    Button1.Text: "Previous day"
    Button1.OnSelect: Set(defaultDate, DateAdd(defaultDate, -1, Days))
    Button2.Text: "Next day"
    Button2.Text: Set(defaultDate, DateAdd(defaultDate, 1, Days))

    In the date picker, you then set its Default property to the "defaultDate" variable, so that when that property is changed (by clicking the previous/next buttons), then the date displayed in the picker will be changed as well.

    DatePicker1.DefaultDate: defaultDate

    The last thing you need to do is to update the "defaultDate" variable when the user selects a new date in the picker's calendar (so that the variable reflects what the date picker is showing, and incrementing / decrementing the date will produce the correct result):

    DatePicker1.OnChange: Set(defaultDate, DatePicker1.SelectedDate)

    Hope this helps!

  • JanSomers91 Profile Picture
    32 on at

    Works like a charm, it was a bit buggy at first but a clean restart fixed all settings!

    Thanks a lot for the quick and helpful response!

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    hello , I am beginner to powerapps.

    i have a table in excel and i fetched it in power apps gallery .

    the gallery has a some fields to show and a Datepicker.

     

    the question is i want to show the same date in DatePicker as default date which was in excel sheet.

    how should i do it?

    datepicker problem powerapps .jpgdatepicker2.jpg

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    This only works on a sharepoint new form , when the parent.default changes in canvas app this logic breaks and prevents users from accessing it. I wish these controls were more well thought on in the design instead of having to implement 72 different work arounds for simple programming procedures. You shouldn't have to manage global variables/update context/set variable functionality for a simple "citizen developer task" 

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 April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 1,045

#2
Valantis Profile Picture

Valantis 675

#3
11manish Profile Picture

11manish 592

Last 30 days Overall leaderboard