cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
biancadevera
Helper III
Helper III

Date not saving in Edit form

I have date picker set to UTC. It works on New form but every time I go to Edit, it shows blank.

 

Data card - Default property

If(
    IsBlank(ThisItem.'Date (UTC)'),
    Now(),
    DateAdd(
        Date(
            1900,
            1,
            1
        ),
        ThisItem.'Date (UTC)',
        Days
    )
)

 

Update

dateUTC.SelectedDate
7 REPLIES 7
powercorner
Responsive Resident
Responsive Resident

hello @biancadevera ,

 

I assume you are storing data in SharePoint? Are you storing with the patch function or are you using a form and the submitform function?


maybe you could send a screenshot of your structural view. So we understand the cotnext better.


With regards
Kevin

powercorner
Responsive Resident
Responsive Resident

hello again @biancadevera 

 

I tried to build an editform with a datecolumn and use the forms.
As you can see on the picture below on the editform I just used the field value when the value is not blank, otherwise I take now()

powercorner_0-1637432156623.png

 

Your approach did not work for the edit form.

 

With regards

Kevin

 

StalinPonnusamy
Super User
Super User

Hi @biancadevera 

 

We can do multiple ways,

 

#1 FormMode

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

 

#2 Using Parent.Default - IsBlank

If(IsBlank(Parent.Default), Now(), Parent.Default)

 

#3

If(IsBlank(ThisItem.'Date (UTC)'), Now(), ThisItem.'Date (UTC)')

 


Thanks,
Stalin - Learn To Illuminate

Hi @StalinPonnusamy  I tried the 3rd option you provided and the value shows up now. However, it goes back at least 1 day. Like when I saved the entry in 11/20/2021 it shows 11/19/2021 in Edit form. Note that I use UTC time for my date picker. 

Hi @biancadevera 

 

The system always stores the DateTime value as UTC in the backend. And setting as local for the Date picker always helps. Any reason why you are using UTC timezone as a date picker?

 

To convert the local to UTC

DateAdd(Now(), TimeZoneOffset(), Minutes )

 

Wise versa, convert UTC to Local

DateAdd( Now(), -TimeZoneOffset(), Minutes )

 

Here is the documentation for TimeZone

 

Thanks,
Stalin - Learn To Illuminate

Hi @powercorner 

I'm using submitform function. The now() seems to work but what if I selected previous dates? It goes back 1 day in Editform. Basically, here's what I want:

  • On new entries, date picker should populate automatically (UTC) but I should also have the ability to select the date
  • On edit form, date values should be the same with what I set on new entry. It shouldn't minus 1 day.
StalinPonnusamy
Super User
Super User

Hi @biancadevera 

 

I'm able to replicate the same issue that you described. Thanks for the explanation. Please try this.

 

  • Set the "Date Time Zone" of the Date Control to UTC as you were
  • Set the DefaultDate property to
If(IsBlank(ThisItem.'Date (UTC)'), DateAdd(Now(), TimeZoneOffset(), Minutes), DateAdd(ThisItem.'Date (UTC)', TimeZoneOffset(), Minutes) )

 

  • Set the Update property of the Date Control to
DateAdd(DateControlName.SelectedDate, TimeZoneOffset(), Minutes)

 

StalinPonnusamy_0-1638330081294.png

 


Thanks,
Stalin - Learn To Illuminate

 

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (2,158)