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

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

Highlighted
Lewkir
Level: Powered On

Re: Convert date to number

Yep this worked.

 

Thanks.