cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FelipeCaru
Advocate V
Advocate V

Date in a text label to be used as proper date in DATEDIFF

Hello all,

I am trying to make a DATEDIFF between a chosen date in a DateValue control as date 1, and a date that is read from an Excel sheet (and it is formatted as date) that is, it seems, text, as date 2. I can't do the DATEDIFF due to this. What can I do?

Sin título.png

"Fin plan" is from the datacard with same name that has inside a label "datacardvalue" and "datacardkey", and if I use the label from it, and a ". " for properties, the first one to show up is ".Text" so it is not valid, it seems, for a datediff. What can I do?

1 ACCEPTED SOLUTION

Accepted Solutions

@FelipeCaru 

Yes, that's exactly right.  For "21/02/2019" - when doing a DateValue on that in en-US, you will get Sept 2 2020

What you will need to do is specify the locale for that date...

DateValue(finPlan.Text, "yourlanguageTag")

_____________________________________________________________________________________
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

4 REPLIES 4
RandyHayes
Super User
Super User

@FelipeCaru 

You will want to convert the text to a DateValue.  DateDiff needs date values to compare.

So, consider this formula:

DateDiff(DateValue(finPlan.Text), DateValue(finReal.Text), Days)

So in the above, substitute the two text items with the field, column, control, or whatever else you have that is giving you a Text Date.

 

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!

@RandyHayes I used a label to test if the DateValue worked, but it didn't give back the same date. Would it be because the one in text is on spanish format (dd/mm/yyyy)? The DateValue one gave me a date on 2020 or so

@FelipeCaru 

Yes, that's exactly right.  For "21/02/2019" - when doing a DateValue on that in en-US, you will get Sept 2 2020

What you will need to do is specify the locale for that date...

DateValue(finPlan.Text, "yourlanguageTag")

_____________________________________________________________________________________
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!

That was exactly what I needed/was missing @RandyHayes , thank you very much

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (2,244)