cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PytByt
Post Prodigy
Post Prodigy

Converting exact text to Data format for compare purpose

Hi all..

 

I'm sorry if i'm been around this too often now.. I still figuring all powerapps function due to my company needs.

 

long story short, i still haven't found satisfying answer to quench my requirements.
So,

I need to comparing text value with date value. 
What i have in mind, is i need to convert my text value into date value. and this is what i have right now:
A variable that store a text value like this:
date4.png

I need to convert that variable value (text: 190301) into date value, so i can use my formula here:
If(DateDiff(Now(), VarExpiryDate, Months)<3,
Notify("Item will be expired in 3 month", NotificationType.Warning);
Set(varEditComment, "Item will be expired in 3 month: [" & Text(VarExpiryDate, "yymmdd") & "]");

I'm thinking to first  convert the text value (190301) into date value something like 01/03/2019 so it could be properly compare. Am i right?
How can i achieve this?
Or is there any other way around to make my formula works?

Please help..

Regards

2 ACCEPTED SOLUTIONS

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @PytByt ,

Could you please share a bit more about your scenario?

Do you want to convert the Text value (e.g. 190301) into a Date value?

 

If you wan to convert the Text value (e.g. 190301) into a Date value, I have made a test on my side, please take a try with the following workaround:

7.JPG

Set the Text property of the Label1 to following (result is Date type value):

Date(Value(Left(Text(Year(Today())),2) & Left(TextInput1.Text,2)), Value(Mid(TextInput1.Text, 3,2)), Value(Right(TextInput1.Text, 2)))

 

On your side, if you want to convert the Text value (VarExpiryDate) into a Date value, you may need to type the following formula:

Date(
    Value(Left(Text(Year(Today())),2) & Left(VarExpiryDate, 2)),    /* <-- Year */
    Value(Mid(VarExpiryDate, 3, 2)),                                /* <-- Month */
    Value(Right(VarExpiryDate, 2))                                  /* <-- Day   */
)

 

Then you need to modify your If formula as below:

If(
   DateDiff(Now(), Date(Value(Left(Text(Year(Today())),2) & Left(VarExpiryDate, 2)),Value(Mid(VarExpiryDate, 3, 2)),Value(Right(VarExpiryDate, 2))), Months) < 3,
   Notify("Item will be expired in 3 month", NotificationType.Warning);
   Set(varEditComment, "Item will be expired in 3 month: [" & VarExpiryDate & "]"
);

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-xida-msft
Community Support
Community Support

Hi @PytByt ,

Could you please share a bit more about your scenario?

Do you want to convert the Text value (e.g. 190301) into a Date value?

 

If you wan to convert the Text value (e.g. 190301) into a Date value, I have made a test on my side, please take a try with the following workaround:

7.JPG

Set the Text property of the Label1 to following (result is Date type value):

Date(Value(Left(Text(Year(Today())),2) & Left(TextInput1.Text,2)), Value(Mid(TextInput1.Text, 3,2)), Value(Right(TextInput1.Text, 2)))

 

On your side, if you want to convert the Text value (VarExpiryDate) into a Date value, you may need to type the following formula:

Date(
    Value(Left(Text(Year(Today())),2) & Left(VarExpiryDate, 2)),    /* <-- Year */
    Value(Mid(VarExpiryDate, 3, 2)),                                /* <-- Month */
    Value(Right(VarExpiryDate, 2))                                  /* <-- Day   */
)

 

Then you need to modify your If formula as below:

If(
   DateDiff(Now(), Date(Value(Left(Text(Year(Today())),2) & Left(VarExpiryDate, 2)),Value(Mid(VarExpiryDate, 3, 2)),Value(Right(VarExpiryDate, 2))), Months) < 3,
   Notify("Item will be expired in 3 month", NotificationType.Warning);
   Set(varEditComment, "Item will be expired in 3 month: [" & VarExpiryDate & "]"
);

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you @v-xida-msft 

Hi @PytByt ,

Is the solution I provided above helpful in your scenario?

 

If the solution I provided above is helpful in your scenario, please consider go ahead to click "Accept as Solution" to identify my solution as Solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-xida-msft 

Yes! 

Thank you.

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (4,999)