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 / RegEx for DateTime in ...
Power Apps
Answered

RegEx for DateTime in 24-hour format

(0) ShareShare
ReportReport
Posted on by 182

I do not like the standard datetime picker from the PowerApps toolbox.  So instead I would like to use just a standard textbox with some RegEx.  For some reason when I run this in the textbox OnChange I always am getting the notification warning.  Can I get another pair of eyes on this and see what might be wrong?  

 

If(
 !IsMatch(txtClearanceDateTime.Text, "^([1-9]|([012][0-9])|(3[01]))[- /.]([0]{0,1}[1-9]|1[012])[- /.]\d\d\d\d (20|21|22|23|[0-1]?\d):[0-5]?\d$,"),
 Notify("You entered an invalid date/time format, please enter value in mm/dd/yyyy hh:mm format", NotificationType.Warning);Reset(txtClearanceDateTime)
 )
Categories:
  • Verified answer
    v-bofeng-msft Profile Picture
    Microsoft Employee on at

    Hi @guyinkalamazoo :

    The key is that there is an extra comma at the end of your regular expression.

    If(
    !IsMatch(txtClearanceDateTime.Text, "^([1-9]|([012][0-9])|(3[01]))[- /.]([0]{0,1}[1-9]|1[012])[- /.]\d\d\d\d (20|21|22|23|[0-1]?\d):[0-5]?\d$,"),
    Notify("You entered an invalid date/time format, please enter value in mm/dd/yyyy hh:mm format", NotificationType.Warning);Reset(txtClearanceDateTime)
    )

    Please try:

    If(
     !IsMatch(txtClearanceDateTime.Text, "^([1-9]|([012][0-9])|(3[01]))[- /.]([0]{0,1}[1-9]|1[012])[- /.]\d\d\d\d (20|21|22|23|[0-1]?\d):[0-5]?\d$"),
     Notify("You entered an invalid date/time format, please enter value in mm/dd/yyyy hh:mm format", NotificationType.Warning);Reset(txtClearanceDateTime)
     )

    36.gif

     Best Regards,

    Bof

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 354 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 330

#3
Mohsin Ali Profile Picture

Mohsin Ali 232

Last 30 days Overall leaderboard