cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Bahalzamon
Advocate II
Advocate II

DateTime CDS Patch

I am attempting to use Patch to update a record within CDS. I just want to update a Date/Time field.

Here is what I have tried and some info:

  • column is a date/time field
  • record exists
  • edited other non date/time data in the record
  • i am the only one working on it
  • have attempted using just Now()
  • using today and adding time to it
  • saving the date/time to a variable then passing that in
  • changing the timezone format to UTC
  • using UpdateIf
  • ensuring I can pull information using my DataTable.Selected
  • using a lookup rather than DataTable.Selected

 

Patch(
    MyPerson,
    DataTable.Selected.Person,
    {
        Column: DateAdd(Now(),3,Days)
    }
)

 

 

I am sure there are many more that I have tried, but this is driving me nuts lol
Any help is definitely appreciated.

1 ACCEPTED SOLUTION

Accepted Solutions
Bahalzamon
Advocate II
Advocate II

@CNT  Just attempted and nothing, I am really unsure why.

@mdevaney Thanks for the reply but I had mentioned I attempted that but I did just attempt again just to be sure I typed it in correctly and no go.

 

I did get it resolved using an UpdateIf, I am unsure why the Patch would not work. Here is my final code that is working.

UpdateIf(
    MyPerson,
    Person=DataTable.Selected.Person,
    {
        Column: DateAdd(Now(),3,Days)
    }
)

 

I am usually hesitant using UpdateIf as it can change multiple records, but as I'm calling the GUID I am safe-ish lol. =P

View solution in original post

5 REPLIES 5
CNT
Super User
Super User

@Bahalzamon What exactly is the problem?

My apologies, nothing happens, no data saved, nothing edited.

I used Errors() as well and nothing

@Bahalzamon I tried and it seems to work. Just to check it on your side, do the following and check if updates the first record.

 

Patch(
    MyPerson,
    First(MyPerson),
    {
        Column: DateAdd(Now(),3,Days)
    }
)

 

mdevaney
Super User
Super User

@Bahalzamon 

I believe the 2nd argument is your problem.  Try this instead.

Patch(
    MyPerson,
    LookUp(MyPerson, Person=DataTable.Selected.Person),
    {
        Column: DateAdd(Now(),3,Days)
    }
)

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Bahalzamon
Advocate II
Advocate II

@CNT  Just attempted and nothing, I am really unsure why.

@mdevaney Thanks for the reply but I had mentioned I attempted that but I did just attempt again just to be sure I typed it in correctly and no go.

 

I did get it resolved using an UpdateIf, I am unsure why the Patch would not work. Here is my final code that is working.

UpdateIf(
    MyPerson,
    Person=DataTable.Selected.Person,
    {
        Column: DateAdd(Now(),3,Days)
    }
)

 

I am usually hesitant using UpdateIf as it can change multiple records, but as I'm calling the GUID I am safe-ish lol. =P

Helpful resources

Announcements
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.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

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