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 / New variable that comb...
Power Apps
Answered

New variable that combines Date and Time variables

(1) ShareShare
ReportReport
Posted on by

I want to create a new variable that will be the date picked from a date picker and the time from a dropdown.

 

The datepicker.SelectedDate is already in Date format, but the time from the dropdown is a text string 

["9:00 AM","9:30 AM","10:00 AM..."4:30 PM","5:00 PM"]

 

I want to set a new variable on the press of a button to combine the two, preferably in Date/Time format. 

 

I've tried setting the date to text and concatenating that string with the time string then converting that back to date/time, I've also tried  

Set(NewDateTimeVariable, Datepicker.SelectedDate + TimeValue(Dropdown.Selected.Value))

but I get the error "Incompatible type. We can't evaluate your formula because the context variable types are incompatible with the types of values in other places in your app."

 

Any ideas?

Categories:
I have the same question (0)
  • Verified answer
    wyotim Profile Picture
    2,545 on at

    I would suggest the following:

     

    Set(
     NewDateTimeVariable, 
     DateTimeValue(
     Datepicker.SelectedDate 
     & " " & 
     TimeValue(Dropdown.Selected.Value)
     )
    )

    I think the "+" in your original formula is causing PowerApps to try and add, rather than concatenate, the two values. By using & " " & instead, it creates a text string which the DateTimeValue function is able to use. Let me know how that works for you.

    *edit* Premature submission! Testing the above code worked for me as far as creating a DateTime value. If that doesn't work, you may need to look at the NewDateTimeVariable to see if it is expecting something else using View -> Variables and selecting NewDateTimeVariable from the list and looking at the Definitions and Uses tabs.

  • Community Power Platform Member Profile Picture
    on at

    Thanks wyotim,

     

    It's strange because I set the dropdown.selected.value to be a variable and the datepicker.SelectedDate to be another variable and when I use the variable names in the exact same place it fails, but when I directly reference the selected values instead of their equivalent set variables it works.  

     

    Oh well, that solves my problem.  Thanks again!

     

     

  • wyotim Profile Picture
    2,545 on at

    @AnonymousThat is a bit strange. Glad the direct references worked though! 

  • muralikrishna00 Profile Picture
    21 on at

    Hi @Anonymous 

     

    Screen shots please ...?

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