Select to view content in your preferred language

Date to number for unique ID

462
2
06-14-2023 05:02 AM
Mathijs_van_der_Sanden
New Contributor

Hello,

I would like to use current date as an automatically generated unique ID when filling out a Field Map Smart Form.

Which function(s) do you need in order to convert a date like Jun 14, 2023, 1:47:43 PM GMT+2 into 20230714134743 for example?

Thank you!

0 Kudos
2 Replies
JohannesLindner
MVP Frequent Contributor

Text()

Text(Now(), "YMMDDHHmmss")

Have a great day!
Johannes
0 Kudos
DougBrowning
MVP Esteemed Contributor

I have a date field that defaults to today then I use this calc (I do this in case there was a tablet issues and they add data the next day). 

This year I added ToLocal because if a crew worked a little late, esp in Alaska, the UTC time can cause the date to be the next day.

Concatenate($feature.PointID, "_", text(ToLocal($feature.FieldEvalDate), "Y-MM-DD"))

Time zones and UTC can be tricky.  123 used to defaut to midnight if there was no time and so this happened all the time.  Now it defaults to noon.  If you have hours in your calc it could change depending on which timezone they are in.  In my case it is a display field so it recalc on display.  On a calculated value you may have to have something to handle this.

0 Kudos