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

Community site session details

Session Id : E/wPDUZL3UN4AgDhb5YzYX
Power Apps - Building Power Apps
Answered

Set Current Date and Time to a Variable

Like (0) ShareShare
ReportReport
Posted on 6 Jun 2024 14:54:58 by 383

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 06 Jun 2024 at 14:59:15
    Re: Set Current Date and Time to a Variable

    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
    383 on 06 Jun 2024 at 15:04:57
    Re: Set Current Date and Time to a Variable

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

  • Trout19 Profile Picture
    383 on 06 Jun 2024 at 15:32:09
    Re: Set Current Date and Time to a Variable

    @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 06 Jun 2024 at 15:37:44
    Re: Set Current Date and Time to a Variable

    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
    383 on 06 Jun 2024 at 15:45:25
    Re: Set Current Date and Time to a Variable

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Chiara Carbone – Community Spotlight

We are honored to recognize Chiara Carbone as our Community Spotlight for November…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 714 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 419 Super User 2025 Season 2

#3
developerAJ Profile Picture

developerAJ 243

Last 30 days Overall leaderboard
Loading started
Loading complete