Search code examples
powerappspowerapps-canvas

How to add a Date Value and a Time Value together in Power Apps?


I have a Power Apps application with two controls, a DatePicker which returns a Date Value, and a Component which returns a Time Value (Power Apps does not yet offer a Time Picker, and Date Picker ONLY sets a date).

So, I have the DATE value from one, and the TIME value from the other. How do I marry the two together? It should be as simple as

dtmMyDate.SelectedDate + compTimePicker.Value

But I get the error "This operation isn't valid on these types: Date, DateTime."


Solution

  • I managed to figure it out, I am adding the answer to help someone else later. The Component returns what LOOKS like a Time Value, but there is still a Date (1/1/1970) so you have to convert it to a TimeValue.

    DateTimeValue(dtmMyDate.SelectedDate + TimeValue(compTimePicker.Value))
    

    Using & " " & instead of + was a helpful suggestion I read, but the plus works fine.