web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to set current dat...
Power Apps
Unanswered

How to set current date as default date in date picker everytime page loads

(0) ShareShare
ReportReport
Posted on by

How to set current date as default date in date picker everytime page loads?

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

    If you want to update a value on the page load, you can create a context variable with the current date on the OnVisible property of the page (screen), and then use that variable as the DefaultDate property of the date picker control:

    Screen1.OnVisible: UpdateContext({currentDate: Today()})
    DatePicker1.DefaultDate: currentDate

    Where DatePicker1 is the name of the date picker control, and Screen1 is the name of the screen which contains the picker.

  • Community Power Platform Member Profile Picture
    on at

    The problem is when I select a different date on my DateField and click on other screen, everytime I go back on the screen that contains my DateField, the DateField defaulted on the date which I set previously.

  • Verified answer
    CarlosFigueira Profile Picture
    on at

    Got it. In order for controls in PowerApps to understand changes in properties (such as the DefaultDate property in the date picker), then the value needs to change. One way to do that is to make two UpdateContext calls in the OnVisible property of that screen, something along the lines of

    UpdateContext({currentDate: Today() - 1}); UpdateContext({currentDate, Today()})

    That will ensure that the value is changed, and the date picker will be notified of it, updating the selected date to the current day.

     

    Another alternative, which is probably preferred, is to "Reset" the date picker control - which causes its selected date to go back to the default value. In this case, you can set the OnVisible property to

    UpdateContext({currentDate: Today()}); Reset(DatePicker1)

    Where 'DatePicker1' is the name of your date picker control.

  • Community Power Platform Member Profile Picture
    on at

    It works. One thing I noticed is that when I go back to the page that contains my DatePicker, PowerApps initially loads the previously selected date and subsequently changes the date to default date. Maybe it was a delay since I also refresh the database. What I did is to put the reset function on OnHidden property. Now when the page load, DatePicker is defaulted to current date.

  • rgparisoto Profile Picture
    220 on at

    Hi guys!

     

    Anyone nows how can I get the complete date? Like these:

    2018-05-17 06:06:00.000

     

    Thank you.

     

    Regards,

    Robson.

  • Community Power Platform Member Profile Picture
    on at

    Can you just put

    Today()

    in the DefaultDate value of the DataCard Value field?

    i.e

    DataCard tmp.jpg

  • CarlosFigueira Profile Picture
    on at

    That should work as well, as long as the app calls one of the form functions (NewForm, EditForm, ResetForm) prior to showing the form to the user, as it will cause the default value to be re-evaluated.

  • Community Power Platform Member Profile Picture
    on at

    Hi All,

     

    I have built a Customised PowerApp Using the Sharepoint List.

    On customised form there is a date picker on which the date is set to Today().

    When we click on add new item to the list then the date is appearing as today's date, but when i try to view the items that are created few days ago then the date is changing to today. HOW CAN I SET THE DATE PICKER PROPERTY TO WHEN NEW ITEM CREATED DATE AS TODAY AND WHEN VIEWING PERVIOUS ITEMS DATE SHOULD NOT CHNAGE TO TODAY.

    Thanks,

    MK

  • CarlosFigueira Profile Picture
    on at

    If the card is in a form, you can use an If expression based on the mode of the form; if it's New, use Today() as the default, otherwise use the existing value, something along the lines of the expression below:

    If(
     EditForm1.Mode = FormMode.New,
     Today(),
     Parent.Default)

    The blog post at https://powerapps.microsoft.com/en-us/blog/default-values-for-complex-sharepoint-types/ talks about setting default values for new items in forms; it's emphasis is for SharePoint lists, but the concepts apply to other data sources as well.

  • Community Power Platform Member Profile Picture
    on at

    Hi,

     

    But my customised Form only has one screen and items are added on sharepoint list and viewed from sharepoint list. 

    When trying to view previous requests the datepicker is changing to today's date.

     

    Thanks,

    MK

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard