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

View solution in original post

3 REPLIES 3
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

View solution in original post

Highlighted
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

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

Demo Extravaganza Championship Voting Open

Voting Ends: October 30, 2019!

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

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