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 / how to reset a datepic...
Power Apps
Answered

how to reset a datepicker defaultdate in a form

(0) ShareShare
ReportReport
Posted on by 34

 have a datepicker in the form that defaults to this Sunday of the week. If the user keeps this interface open, the default date will not change. If the user submits the form next week, the default date is still last Sunday. I just want to give the user a button to submit the form. How can I make the user refresh this default date automatically every time they submit, and set it to the Sunday date when the user submits? thanks. 

Categories:
I have the same question (0)
  • mmbr1606 Profile Picture
    14,605 Super User 2026 Season 1 on at

    hey @EricDa 

     

    can u try this in the default of date picker

    DateAdd(Today(), 7 - Weekday(Today()), Days)
    

     

    and this in button onselect:

    Reset(NextSundayPicker);
    SubmitForm(YourFormName); // Replace 'YourFormName' with the actual name of your form if you're submitting a form
    

     

    Let me know if my answer helped solving your issue.

    If it did please accept as solution and give it a thumbs up so we can help others in the community.



    Greetings

  • v-yueyun-msft Profile Picture
    Microsoft Employee on at

    HI , @EricDa 

    According to your description, you want to always add the Sunday in your side.

    For example , this is my test data:

    vyueyunmsft_0-1716529075583.png

    We need to use this expression:

    DataCard - Default:
    If(Form1.Mode= FormMode.New ,Today()-Weekday(Today(),StartOfWeek.Monday)+1+6 , ThisItem.WeekStart)

    DataCard - Update: (This determines what data you submit to the data source )

    Today()-Weekday(Today(),StartOfWeek.Monday)+1+6

     

    Button- OnSelect:
    SubmitForm(Form1);ResetForm(Form1);

     

    If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance! 

     

    Best Regards,

    Yueyun Zhang

     

  • EricDa Profile Picture
    34 on at

    thanks for your reply, the datepicker is in the form, i cannot use reset() to reset it. i can only insert a icon into that datacardcontrol and set icon.onselect to hold reset(). but i dont want to user to click the icon, i only want to use click the submitform button. 

  • Verified answer
    Gochix Profile Picture
    1,935 Moderator on at

    @EricDa ,

     

    Set your defaultDate in datepicker to varDate

    then on your submit button:

    Set(varDate,
    DateAdd(Today(), 
     With({
     _sday:Weekday(Today(), StartOfWeek.Sunday)},
     If(
     _sday>=5, 8-_sday,1)),
     TimeUnit.Days)
    )


    _____________________________________________________________________________________
    Please give a thumbs up if I resolved your issue! Please click Accept as Solution to close the topic!

  • EricDa Profile Picture
    34 on at

    thanks for reply, i have no problem with setting defaultdate of datepicker. as i mentioned, if today date is May 24, 2024, the defaultdate of datepicker is May 26, 2024. if user leave the app interface(form) open untill May 27, 2024, then submit the form on May 27, the defaultdate of datepikcer is still remain on May 26 which is not what i want. i also dont want to user to use resetform(), because user will lost all the fill in information in the form. 

  • Verified answer
    v-yueyun-msft Profile Picture
    Microsoft Employee on at

    HI , @EricDa 

    If you always want to save the date after submitting the form as the Sunday of the time the user clicks the submit button. You can update this field:

    DataCard - Update: ï¼ˆThis determines what data you submit to the data source )

    Today()-Weekday(Today(),StartOfWeek.Monday)+1+6

     

    This way, no matter what the user chooses, the submission will always be the Sunday of the week on which the button is clicked.

     

    If this reply can help you , you can click mark this reply as solution (Accept solution) which can help more people, thanks in advance! 

     

    Best Regards,

    Yueyun Zhang

     

  • EricDa Profile Picture
    34 on at

    thanks. let me try this. 

  • EricDa Profile Picture
    34 on at

    Thanks. i think that will also do the trick, but let me try use veriable, it will update defaultdate too. 

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!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 88

#2
WarrenBelz Profile Picture

WarrenBelz 85 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 45

Last 30 days Overall leaderboard