web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Set Current Date and T...
Power Apps
Unanswered

Set Current Date and Time to a Variable

(0) ShareShare
ReportReport
Posted on by 395

I am wanting to create a unique id with the current date and time. I have it set to set the variable in the StartScreen currently.

2024-06-06_09-51-20.jpg

Also, how would you clean the record up to have a string of numbers only. For example, 06062024953

Categories:
I have the same question (0)
  • Verified answer
    madlad Profile Picture
    2,637 Moderator on at

    Hi!

     

    To do this, it should just be something along the lines of:

    If(IsBlank(Param("ID")), Set(VarRand, Text(Now(), "mmddyyyyhhmmss")))

    The if function is just what you already had, and "Text(Now(), "mmddyyyyhhmmss")" formats it as you specified.

     

    Hope this helps!

  • Trout19 Profile Picture
    395 on at

    Great thanks, I had to move it to on Start for it to work. 

  • Trout19 Profile Picture
    395 on at

    @madlad I put varRand in a textbox text control to test it and it is not coming through. 2024-06-06_10-31-14.jpg

  • Verified answer
    madlad Profile Picture
    2,637 Moderator on at

    Looks like it's Blank currently - try running OnStart from the 'App' Selection in the Screen view and see if that sets it

    madlad_0-1717688242110.png

     

    Let me know how it goes!

     

  • Trout19 Profile Picture
    395 on at

    Ok it populated. I moved to the create new button so it would create when I created a new item. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard