web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patching Date and Time
Power Apps
Answered

Patching Date and Time

(0) ShareShare
ReportReport
Posted on by 1,257 Super User 2024 Season 1

I collect a date from a DatePicker and minute/hour from dropdowns as follows:

 

CommencedTime: DPDate1.SelectedDate & (DDHourValueBC.Selected.Value & "." & (DDMinuteValueBC.Selected.Value)),

 

works fine but when I go to try patch it back to the SP list (datetime field) I'm running into problems..

 

Commenced:DateValue(CommencedTime)

 

saying it doesn't recognise it as a date/time value

 

I've tried numerous variation of the above also. My problem is that the date I need is in one Date picker and the hours and minutes are in separate DropDowns.  If I leave out the Datepicker all together and just try to patch back the results from the drop down those work fine for the hours/minutes but obviously the date is wrong...  Have also tried DateTimeValue(   infront.

 

any suggestions.       Should I be collecting the full date and time at the collection level or only when I go to patch it back? because the date field is used on it's own anyway in the collection..

 

TIA

Categories:
I have the same question (0)
  • Adam1986 Profile Picture
    139 on at

    Hi @vffdd,

    If you look what is in Update property of Form DataCard for date and time column you can see that it is formated like this.

    DateValue1.SelectedDate + Time(Value(HourValue1.Selected.Value), Value(MinuteValue1.Selected.Value), 0)

    Mayby you should build your custom date and time picker like Form DataCard for date and time column.

     

  • vffdd Profile Picture
    1,257 Super User 2024 Season 1 on at

    thanks @Adam1986  but it's not a form so no update 

  • Verified answer
    Adam1986 Profile Picture
    139 on at

    @vffdd 

    I know this is not form and there is no Update property. But this is what you should Patch.Capture.JPG

    This is solution for your approach.

    Just patch as follows:

     

    Patch(
     Adam_test,
     {
     DateStart: DateValue1.SelectedDate + Time(
     Value(HourValue1.Selected.Value),
     Value(MinuteValue1.Selected.Value),
     0
     )
     }
    )

     

     

  • Adam1986 Profile Picture
    139 on at

    Remember that date and time is actually a number so your approach with '&' is incorrect. You need to add date to hours and minutes to calculate single column date and time value.

  • vffdd Profile Picture
    1,257 Super User 2024 Season 1 on at

    ok I'll remove the & so and play around with it. Unfortunately I can't use your approach as I have to use the date that has been added to the collection. Reason being this app is used offline as well as on and the patch may not take place till a day later so the date picked from the drop down won't be valid.   The collection is saved to a local file after collected and then that populates the collection next time app starts.. so I have to use the date that was collected !

  • iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    @vffdd it's clear that @Adam1986 was referring to the way you are constructing the date, not the patching itself.

     

    You said yourself that you collect dates like this:

    CommencedTime: DPDate1.SelectedDate & (DDHourValueBC.Selected.Value & "." & (DDMinuteValueBC.Selected.Value)),

    So instead now you will collect them like this:

    CommencedTime: DPDate1.SelectedDate + Time(Value(DDHourValueBC.Selected.Value), Value(DDMinuteValueBC.Selected.Value), 0),
  • Adam1986 Profile Picture
    139 on at

    @vffdd, then collect and store this date-time value as number in your local file.

     

    Value(
     DateValue1.SelectedDate + Time(
     Value(HourValue1.Selected.Value),
     Value(MinuteValue1.Selected.Value),
     0
     )
    )

     

    then just Patch that value to sharepoint. I dont see any issue with this solution. If u got correct date and time as value you can collect or patch it like you want.

    Like this below, outcome will be the same.

     

    Patch(
     Adam_test,
     {
     DateStart: 1683687840000
     }
    )

     

     

  • Adam1986 Profile Picture
    139 on at

    @vffdd , @iAm_ManCat is right,

    I see that i should be more specific. I suggested approach to get, collect, patch value that represents your date time value. What you need to do with it is your decision. There is many options how you can handle this solution.

  • vffdd Profile Picture
    1,257 Super User 2024 Season 1 on at

    ok great thanks for your help, let me play around with that and see if I can get it to work 🙂

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard