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 / Date Changing When edi...
Power Apps
Answered

Date Changing When editing PowerApp

(0) ShareShare
ReportReport
Posted on by 16

Hello,

 

I created my first PowerApp to be used to allow my department to input some data that goes to a SharePoint list.  In this PA I have a date field that autogenerates the date for 30 days past today's date.

 

default date for this datacard is set to 

DateAdd(Now(),31,TimeUnit.Days)
 
This works great on creation but when editing from inside the PA the date goes 30 days ahead of the day of edit.  Meaning if I created the record on 5/1 that date would be 6/1, great!  But if I edit on 5/7 the date would change to 6/7, not great.  I understand that it is because the formula I am using for the default date.  But I am not sure what I could use to make it work better.  An IF statement I imagine but I am a noob to this stuff.  🙂
 
My goal is when created to have the date field go to 30 days ahead BUT when editing the date does not change.
 
I hope this makes sense,
Thanks
Rich
Categories:
  • Verified answer
    Rajkumar_M Profile Picture
    3,747 Moderator on at

    Hi @richard_k 

     

    In the DefaultDate property of the date picker control (or the Default property of the data card), use the following formula:

     

    If(
    YourFormName.Mode = FormMode.New,
    DateAdd(Today(), 30, TimeUnit.Days),
    Parent.Default
    )

     

    Thanks!

     

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

  • richard_k Profile Picture
    16 on at

    Thanks for the quick response.  I added your suggestion and while it does retain the original date on editing in the PA when I do a "New" entry the date is 12/31/2001 instead of 6/24/24

     

    I edited DefaultDate to

    If(
    DataCardValue5.DisplayMode = FormMode.New,
    DateAdd(Today(), 30, TimeUnit.Days),
    Parent.Default
    )
  • Rajkumar_M Profile Picture
    3,747 Moderator on at

    Make sure you are using the form's Mode property, not the DisplayMode of a control.


    Use FormMode.New and FormMode.Edit to determine whether you are creating a new record or editing an existing one.

     

    If(
    YourFormName.Mode = FormMode.New,
    DateAdd(Today(), 30, TimeUnit.Days),
    Parent.Default
    )

     

     

    Thanks!

     

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

  • richard_k Profile Picture
    16 on at

    Ah, I thought I had to use the datacardvalue and ".mode" was not an option on displaymode.  🙂

     

    That seems to have done it when I used my form name instead.  Thank you!

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 258

#3
Mohsin Ali Profile Picture

Mohsin Ali 231

Last 30 days Overall leaderboard