cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ReinerKnudsen
Advocate I
Advocate I

Combine date string for DateDiff

I have a date picker for my date (date_Von) and a text field for my time (txt_zeitVon). 

I have two sets of these (date_Von and date_Bis, txt_zeitVon and txt_zeitBis) and want to compare them with DateDiff.

 

My problem is that building a valid expression for DateDiff fails.

I try 

DateTimeValue( 
date_Von.SelectedDate & " " & txt_zeitVon.Text)

as well as

DateTimeValue( 
date_Bis.SelectedDate & " " & TimeValue(txt_zeitBis.Text)) 

What is really funny is that DateDiff works for both of them, but PowerApps always gives me an error saying:

The arguments to the DateTimeValue function do not represent a valid date or time value.

Any idea why PowerApps won't like my expressions?
Thanks for your help.

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@ReinerKnudsen 

Convert your date to text in your formula...

Please consider changing your Formula to the following:

DateTimeValue( 
        Text(date_Von.SelectedDate, ShortDate) & " " & txt_zeitVon.Text
)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

1 REPLY 1
RandyHayes
Super User
Super User

@ReinerKnudsen 

Convert your date to text in your formula...

Please consider changing your Formula to the following:

DateTimeValue( 
        Text(date_Von.SelectedDate, ShortDate) & " " & txt_zeitVon.Text
)

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Top Solution Authors
Top Kudoed Authors
Users online (4,125)