How to set date and time with mm/dd/yyyy hh:mm:ss AM/PM format in InfoPath

Problem

To set the date and time with mm/dd/yyyy hh:mm:ss AM/PM format in InfoPath

Solution

Use the below function

concat(substring(today(), 6, 2), “/”, substring(today(), 9, 2), “/”, substring(today(), 1, 4), ” “, substring(“0”, 1, substring(substring-after(now(), “T”), 1, 2) mod 12 + 12 * (substring(substring-after(now(), “T”), 1, 2) mod 12 = 0) < 10), substring(substring-after(now(), “T”), 1, 2) mod 12 + 12 * (substring(substring-after(now(), “T”), 1, 2) mod 12 = 0), substring(substring-after(now(), “T”), 3, 6), ” “, substring(“AP”, 1 + (substring(substring-after(now(), “T”), 1, 2) >= 12), 1), “M”)

That’s it you are done 🙂

One thought on “How to set date and time with mm/dd/yyyy hh:mm:ss AM/PM format in InfoPath

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.