Skip to main content

Notifications

Power Platform Community / Forums / Build A Canvas App / Check Text syntax for ...
Build A Canvas App
Answered

Check Text syntax for correct time format

Posted on by 680
Good day,
 
I am trying to determine if there is a syntax to determine if a user were to input text into a text field to determine if it was in the format "HH:mm AM/PM"
I found a suggestion online with the format below but it always returns as false. I have tried the values:
  • 10:00am
  • 10:00 am
  •  1:00 am
  • 1:00 PM
Match formula I am using,
If(IsMatch(txtScheduleMonday.Text, "(1[0-12][1-9]):[0-5][0-9] ([AaPp][Mm])", "true","false")
 
Categories:
  • Verified answer
    rpersad Profile Picture
    rpersad 680 on at
    Check Text syntax for correct time format
     
    I was doing but I want to allow the user to enter multiple schedule periods, eg. "10:00am-11:00am, 12:00pm-3:00pm". I would like to add an option to allow users to select a time using drop-down controls but due to time constrains for development it would have to be done on a later version.
     
    I was able to find a Regex solution for all scenario's I listed in my question. Reference link to where I found the answer, https://stackoverflow.com/a/39280605/10552347. Note, this answer is for a 12 hr time format and not a 24 hr time format.
    ([0-9]|0[0-9]|1[0-9]|2[0-3]):([0-5][0-9])\s*([AaPp][Mm])
    This will work for all scenarios listed below:
    • 10:00am
    • 10:00 am
    •  1:00 am
    • 1:00 PM
    • 6:00 Am
     
     
  • Suggested answer
    Nandit Profile Picture
    Nandit 1,091 on at
    Check Text syntax for correct time format
    Hi rpersad,
     
    I would suggest not using Input Text control for this. Use multiple controls and then create a string using them. Something like this:
    These are three dropdowns. 
    Hour Dropdown Items:
    [1,2,3,4,5,6,7,8,9,10,11,12]
    Minute Dropdown Items:
    [00, 15,30,45]
    AM/PM Dropdown:
    ["AM", "PM"]
    Final String:
    Concatenate(
        drpdwn_Hour.Selected.Value,
        ":",
        drpdwn_Min.Selected.Value,
        " ",
        drpdwn_AMPM.Selected.Value
    )
     
    Hope this helps. This should make it easier to get inputs from the user.
     
    Kind regards, 
    Nandit
     
    If this answers your query, please mark this response as the answer.
    If its helpful, please leave a like. Thanks!
     
     

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

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 142,008

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,531

Leaderboard

Featured topics