cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
guyinkalamazoo
Frequent Visitor

RegEx for DateTime in 24-hour format

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)
    )
1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

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

View solution in original post

1 REPLY 1
v-bofeng-msft
Community Support
Community Support

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

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (62,355)