cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lewkir
Level: Powered On

Convert date to number

So I am trying to make a unique ID out of a date and need to conviert it to a number ideally in the format yyymmdd.

 

I can get the date picker to display this way but when I try to put it in a label it converts it back to dd/mm/yyyy.

 

When I try:

Text(FromDate,"yyyymmdd") 

Powerapps still displays it dd/mm/yyyy and converts the code to:

Text(FromDate,"[$-en-US]yyyymmdd") 

Not sure why this is happening.

 

Can anyone help me out?

 

Cheers,

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
egallis
Level 10

Re: Convert date to number

Hi @Lewkir,

That's normal behavior from PowerApps. When using the Text() function, if you specify a format (like "yyyymmdd"), PowerApps will automatically add the "[$-en-US]" prefix to your format to tell the system what locale format to use. But in the end, you get the same result.

If you set the Default property of a text input control to Text(FromDate,"[$-en-US]yyyymmdd"), it will show your date with that format. You can then convert it to a integer using the Value() function.

Hope this helped,

Emmanuel

3 REPLIES 3
Highlighted
egallis
Level 10

Re: Convert date to number

Hi @Lewkir,

That's normal behavior from PowerApps. When using the Text() function, if you specify a format (like "yyyymmdd"), PowerApps will automatically add the "[$-en-US]" prefix to your format to tell the system what locale format to use. But in the end, you get the same result.

If you set the Default property of a text input control to Text(FromDate,"[$-en-US]yyyymmdd"), it will show your date with that format. You can then convert it to a integer using the Value() function.

Hope this helped,

Emmanuel

Lewkir
Level: Powered On

Re: Convert date to number

Yep this worked.

 

Thanks.

cederbusch
Level: Powered On

Re: Convert date to number

I can´t get this to work. Followed per instruction, still shows "yyyy-mm-dd". 

Eventually used Substitute to remove all the "-".

Substitute(Text(FromDateDatePicker;"[$-us-US]yyyymmdd");"-";"")

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 382 members 4,932 guests
Please welcome our newest community members: