Hi, I'm struggling to implement a custom date time format regular expression for the following format: MM/DD/YYYY, hh:mm A Example: 1/24/2023 11:30 AM I tried something this, but not sure how to implement it in a regex action: \d{2}/\d{2}/\d{4}\s+\d{2}:\d{2}\s+(AM|PM)
I also tried to do it on a task form, however could not do it on a submit rule (its used for a comment log, so it has to be on the submit rule).
Also tried the format date action, but it returns the seconds as well as a day behind from the current date time for some odd reason
Explanation: If the time is 00:00:01 or 00:30:20, we are going to format it as 12:00 AM or 12:30 AM
BRANCH If int_Hours == 12
Step 06b: Apply Regex
Input: txt_FormatTime (Output from Step 3)
Replace
Pattern: (\d{2}):(\d{2}):(\d{2})
Replacement: 12:$2 PM
Output: txt_FormatTime
Explanation: If the time is 12:00:01 or 12:30:20, we are going to format it as 12:00 PM or 12:30 PM
BRANCH If int_Hours < 12
Step 06c: Apply Regex
Input: txt_FormatTime (Output from Step 3)
Replace
Pattern: (\d{2}):(\d{2}):(\d{2})
Replacement: int_hour:$2 AM
Output: txt_FormatTime
Explanation: Get hours and minutes, append AM
BRANCH If int_Hours < 12 (The NO branch)
Additional Step → Minus 12 from int_Hours
Step 06d: Apply Regex
Input: txt_FormatTime (Output from Step 3)
Replace
Pattern: (\d{2}):(\d{2}):(\d{2})
Replacement: int_hour:$2 PM
Output: txt_FormatTime
Explanation: Get hours and minutes, append PM
TESTING RESULT
I used a Datetime control for input instead of getting the actual Datetime from Context
Hope that helps
Hi,
My reaction:
I think I will just use one of the built in formats in the convert a value action to avoid too many steps (unless it has to be in that specific format). Thanks for this solution though :)
If you haven’t voted for it already, there’s an idea out there to add more options to the Format Date to String action.