Format Time from the now() - InfoPath Dev Sign in | Join | Help in General InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » General » Format Time from the now() Use our Google Custom Search for best site search results. Format Time from the now() Last post 02-05-2014 08:49 AM by jaxkookie. 4 replies. Page 1 of 1 (5 items) Sort Posts: Oldest to newest Newest to oldest Previous Next 02-04-2014 02:00 PM jaxkookie Joined on 05-02-2007 jacksonville FL Posts 187 Format Time from the now() Reply Contact I have a CommentsHistory field, Every time comments are entered into the Comment field, I concat, timestamp, comments ,commentshistory , timestamp in the now() like thisconcat(substring(now(), 6, 2), "/", substring(now(), 9, 2), "/", substring(now(), 1, 4), " ", substring(now(), 12, 2), ":", substring(now(), 15, 2), ":", substring(now(), 18, 2)) what I want to do is check this substring(now(), 12, 2) (the Hour) and if value is greater than 12, I want to subtract 12 and set PMOn change of my comments field I have this conditionThe expression : round(substring(now(), 12, 2)) > 12 but it is giving an error. Am I missing something? Kind regards,Larry Filed under: time format 02-04-2014 08:38 PM In reply to Jimmy Joined on 07-03-2008 Posts 2,594 Re: Format Time from the now() Mark as Not AnswerMark as Answer... Reply Contact Here's how you can adjust the hour number:substring(now(), 12, 2) mod 12 + 12 * not(substring(now(), 12, 2) mod 12)And here's how you can get the AM/PM part:substring("AMPM", 1 + 2 * (substring(now(), 12, 2) >= 12), 2)Note that if you have qRules, you can use the FormatDate command to do this much more easily:concat("FormatDate /format=G /value=", now()) <-- this is locale dependent, but will produce the M/d/yyyy hh:mm:ss tt format in the US locale.concat("FormatDate /format=MM/dd/yyyy hh:mm:ss tt /value=", now()) <-- not locale dependent Jimmy Rishe / Software Developer / Microsoft MVPQdabra Software 02-05-2014 05:40 AM In reply to jaxkookie Joined on 05-02-2007 jacksonville FL Posts 187 Re: Format Time from the now() Mark as Not AnswerMark as Answer... Reply Contact Jimmy, you rock, once again! So this work in the client, but not in the browser. When I publish I get an unsupported expression, when I open from the library it opens in the client now. If I didn't say this in ver 2007. this is my complete formula concat(substring(xdDate:Now(), 6, 2), "/", substring(xdDate:Now(), 9, 2), "/", substring(xdDate:Now(), 1, 4), " ", substring(xdDate:Now(), 12, 2) mod 12 + 12 * not(substring(xdDate:Now(), 12, 2) mod 12), ":", substring(xdDate:Now(), 15, 2), " ", substring("AMPM", 1 + 2 * (substring(xdDate:Now(), 12, 2) >= 12), 2)) the parts you provided are in red and blue. when I remove the red, it works.do you have any other magic tricks? Kind regards,Larry 02-05-2014 07:45 AM In reply to Jimmy Joined on 07-03-2008 Posts 2,594 Re: Format Time from the now() Mark as Not AnswerMark as Answer... Reply Contact Please try this for the red part. My original version may have been a little too funky: substring(now(), 12, 2) mod 12 + 12 * ((substring(now(), 12, 2) mod 12) = 0) Jimmy Rishe / Software Developer / Microsoft MVPQdabra Software 02-05-2014 08:49 AM In reply to jaxkookie Joined on 05-02-2007 jacksonville FL Posts 187 Re: Format Time from the now() Mark as Not AnswerMark as Answer... Reply Contact thanks brother, you rock! works perfectly. I wont pretend to understand it, lol Kind regards,Larry Page 1 of 1 (5 items) Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.
Use our Google Custom Search for best site search results.
I have a CommentsHistory field, Every time comments are entered into the Comment field, I concat, timestamp, comments ,commentshistory , timestamp in the now() like this
concat(substring(now(), 6, 2), "/", substring(now(), 9, 2), "/", substring(now(), 1, 4), " ", substring(now(), 12, 2), ":", substring(now(), 15, 2), ":", substring(now(), 18, 2))
what I want to do is check this substring(now(), 12, 2) (the Hour) and if value is greater than 12, I want to subtract 12 and set PM
On change of my comments field I have this condition
The expression : round(substring(now(), 12, 2)) > 12 but it is giving an error.
Am I missing something?
Here's how you can adjust the hour number:
substring(now(), 12, 2) mod 12 + 12 * not(substring(now(), 12, 2) mod 12)
And here's how you can get the AM/PM part:
substring("AMPM", 1 + 2 * (substring(now(), 12, 2) >= 12), 2)
Note that if you have qRules, you can use the FormatDate command to do this much more easily:
concat("FormatDate /format=G /value=", now()) <-- this is locale dependent, but will produce the M/d/yyyy hh:mm:ss tt format in the US locale.concat("FormatDate /format=MM/dd/yyyy hh:mm:ss tt /value=", now()) <-- not locale dependent
concat("FormatDate /format=G /value=", now()) <-- this is locale dependent, but will produce the M/d/yyyy hh:mm:ss tt format in the US locale.
concat("FormatDate /format=MM/dd/yyyy hh:mm:ss tt /value=", now()) <-- not locale dependent
Jimmy,
you rock, once again!
So this work in the client, but not in the browser. When I publish I get an unsupported expression, when I open from the library it opens in the client now. If I didn't say this in ver 2007.
this is my complete formula
the parts you provided are in red and blue. when I remove the red, it works.
do you have any other magic tricks?
Please try this for the red part. My original version may have been a little too funky:
substring(now(), 12, 2) mod 12 + 12 * ((substring(now(), 12, 2) mod 12) = 0)
thanks brother, you rock! works perfectly. I wont pretend to understand it, lol