cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PytByt
Level 8

How to Auto change text format into date format

Hello, 

Is there any way to make our input text auto change format into date format?

For example:
Input text: 190301   ----->>   Auto change into date format: 01/03/2019


Regards.

1 ACCEPTED SOLUTION

Accepted Solutions
cds
Level 8

Re: How to Auto change text format into date format

OK so here is your label: 

VarDay&"/"&VarMonth&"/"&VarYear

On your TextInput.OnChange put this:

UpdateContext({VarYear: "20"& Left(TextInput.Text, 2), VarMonth: Mid(TextInput.Text, 3,2), VarDay: Right(TextInput.Text, 2)})

This solution wont work for 1900's or 2100's

View solution in original post

14 REPLIES 14
cds
Level 8

Re: How to Auto change text format into date format

Yes, but you would have to be consistent in how you write it. you cant just do a random string like 190215 and expect it to know that means d/m/y... 

 

DateValue(Text(textinput.text, "m/d/yyyy"))

PytByt
Level 8

Re: How to Auto change text format into date format

Hi @cds 

Thank for your reply.

Is it works if i use a text box control?

cds
Level 8

Re: How to Auto change text format into date format

you will have to set it as a global or contextual variable.. 
OnChange = Set(ThisDate, DateValue(Text(TextInput.Text, "mm/dd/yyyy"))) 

PytByt
Level 8

Re: How to Auto change text format into date format

Hi @cds 

I try your formula both in variable and direct to the text box, but i dont get the result as i hoped:

date6.png

you see, the result is 1/1/1903 when i entered the text value as 190301

what i needed is 01/03/2019 as date format result.

I'm hoping to get this:
Text box value: 190301
Date format result: 01/03/2019 (dd/mm/yyyy) or 03/01/2019 (mm/dd/yyyy)

Is this achieveable with powerapps?

cds
Level 8

Re: How to Auto change text format into date format

It is possible but you are going to have to do some serious string manipulation

 

PytByt
Level 8

Re: How to Auto change text format into date format

can you help?

cds
Level 8

Re: How to Auto change text format into date format

OK so here is your label: 

VarDay&"/"&VarMonth&"/"&VarYear

On your TextInput.OnChange put this:

UpdateContext({VarYear: "20"& Left(TextInput.Text, 2), VarMonth: Mid(TextInput.Text, 3,2), VarDay: Right(TextInput.Text, 2)})

This solution wont work for 1900's or 2100's

View solution in original post

PytByt
Level 8

Re: How to Auto change text format into date format

@cds 

This is wonderful!
I will try it as soon as i arrived at the HQ.

Thanks in advance!

Ps.
I may have follow up questions for i am a noob in powerapps programming language.

PytByt
Level 8

Re: How to Auto change text format into date format

@cds 

Where should i put this:
VarDay&"/"&VarMonth&"/"&VarYear

?

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (6,056)