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 / Setting the default va...
Power Apps
Answered

Setting the default value for a Date field as "Today()" will always show today date

(0) ShareShare
ReportReport
Posted on by 3,514

I set the default value for a date field to be equal to Today(), but even when i edit an item which have a date value, the date value will be set to Today.. and advice on this, how i can preserve the value of the Date field?

 

today.png

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,925 on at

    Consider this:

    If(YourFormName.Mode=FormMode.Edit,Parent.Defaut,Today())

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • johnjohn123 Profile Picture
    3,514 on at

    @eka24

    but if in edit mode the field does not have a value then i need to set it to the default.. your formula will not work is this correct?

     

    i tried this formula "If(IsBlank(Parent.Default),Today(),Parent.Default)" but it did not fix the issue....

     

  • eka24 Profile Picture
    20,925 on at

    The formula is on the EditMode not a new form. 

    If it in a NewMode, it will pick Today().

    For EditMode, it picks whatever value is in the datasource, so if its blank in the datasource, the datefield will also be blank. Until the user changes the date

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • johnjohn123 Profile Picture
    3,514 on at

    @eka24but if the date field is empty then i need it to get Today() by default i tried this formula "If(IsBlank(Parent.Default),Today(),Parent.Default)" but it did not fix the issue

  • eka24 Profile Picture
    20,925 on at

    In that case create a variable OnVisible of the Screen:

    Set(varDate,DateValue1.SelectedDate)
     

    Then Change the formula to:

    If(!IsBlank(varDate) && Form1.Mode=FormMode.Edit,Parent.Default,Today())
     
    Remember after setting the variable, navigate to a different screen and back before it takes effect
    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.
  • johnjohn123 Profile Picture
    3,514 on at

    @eka24i did not get your point.. why i need to use a variable ? why i can not simply say "If(IsBlank(Parent.Default),Today(),Parent.Default)"??

  • eka24 Profile Picture
    20,925 on at

    Parent.Default will not work for New Mode (NewForm)

    I guess the formula should work both for new and edit mode?

    Again Parent.Default is not a control

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • johnjohn123 Profile Picture
    3,514 on at

    @eka24  can you please explain your point :-

     

    Parent.Default will not work for New Mode (NewForm)

    I guess the formula should work both for new and edit mode?

    Again Parent.Default is not a control

     

    in more details?

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @johnjohn123 

    Hmmm...didn't we just cover Coalesce in another thread?? 😉

        Coalesce(Parent.Default,Today())

    If there is a value in the underlying record, use that, if not, use Today()

     

  • eka24 Profile Picture
    20,925 on at

    Generally, the formula IsBank() should reference the Date picker. That is if the Date picker is Blank, then Today.

    Now this create a circular reference. That is the more reason I used the variable.

     

    The formula you quoted doesn't make any reference on the mode of the form. That is why in your original post both edit mode and new mode of the form gave you Today's date without any retrieval of Data from the Datasource.

     

    Now on your formula. 

    Does this work:

    "If(IsBlank(Parent.Default),Today(),Parent.Default)"??

     

    Also does the approach I gave work?

     

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

     

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 893

#2
Valantis Profile Picture

Valantis 571

#3
11manish Profile Picture

11manish 482

Last 30 days Overall leaderboard