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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 993

#2
Valantis Profile Picture

Valantis 675

#3
11manish Profile Picture

11manish 545

Last 30 days Overall leaderboard