Showing results for 
Search instead for 
Did you mean: 
New Member

validate date and time format

Hi Everyone,


I have a flow that require user to insert the date and time format like: "YYYY-MM-DDTHH:MM"

I would like to trigger an error message if user insert the format wrongly. 

(e.g. to insert the date and time like: "YYYY-MM-DDTHHMM"/"YYYY-MM-DDTHHH:MM"/"YYYY-MM-DDT:HH:MM")


I am not sure how to write the condition for validate this, is there any idea?



Dual Super User III
Dual Super User III

Unfortunately Power Automate doesn't support any kind of Regular Expression function.  But since the required format is fixed length the approach I would use is to check where the punctuation and special characters are using IndexOf() and LastIndexOf().  For example

Indexof(InputText, 'T') = 10
Indexof(InputText, '-') = 4
LastIndexof(InputText, ':') = 13

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Solution Sage
Solution Sage

Typically you would handle input validation in PowerApps input (not sure if you are using that).  However, here is a flow that will perform validation on your input, and you could then use the condition output to do different things (proceed with flow vs. notify the person the format was wrong, etc.).




Here are the key expressions (also shown in the comments for each step).

Validation - array 

[{"position":4, "character": "-"}, {"position":7, "character": "-"}, {"position":10, "character": "T"}, {"position":13, "character": ":"}]


Filter step (filters validation array where the position and character match)

equals(equals(item()?['character'], substring(outputs('InputValue'), item()['position'], 1)), true)
Condition check (check that the length of the input is 16 characters, and that the all the validation filters rows are kept (equals 4))
and(equals(length(outputs('InputValue')),16), equals(length(body('Filter_array')),4))
New Member

Solved, thanks all!

Helpful resources

Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA 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 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 (63,605)