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
Super User
Super User

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
Super User
Super User

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
Community Champion
Community Champion

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
Community Champion
Community Champion

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
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,449)