set date and time to display in mm/dd/yyyy hh:mm:ss AM/PM format in textbox - InfoPath Dev Sign in | Join | Help in Newbie Questions 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 » Newbie Questions » set date and time to display in mm/dd/yyyy hh:mm:ss AM/PM format in textbox set date and time to display in mm/dd/yyyy hh:mm:ss AM/PM format in textbox Last post 01-04-2012 10:16 PM by Jimmy. 5 replies. Page 1 of 1 (6 items) Sort Posts: Oldest to newest Newest to oldest Previous Next 01-04-2012 07:18 AM venkatzeus Joined on 12-30-2010 Posts 46 set date and time to display in mm/dd/yyyy hh:mm:ss AM/PM format in textbox Reply Contact Hi,I have added 3 textboxes. one having date only. Another having time only. In the third textbox, i would like to have the concatenated value. First textbox - Data type as Date - shows result as : 01/04/2012 Second textbox - Data type as Time - shows result as : 06:57:11 AM ( i used this formula: substring-after(now(), "T") ) Third textbox - Data type as Text(string). I have added the rule for concatenating as : concat(field1, field2) However the Third textbox is displaying result as : 2012-01-0406:57:11 I need to show in the third textbox as : 01/04/2012 06:57:11 AM How to achieve this? Thank you 01-04-2012 07:57 AM In reply to Jimmy Joined on 07-03-2008 Posts 2,595 Re: set date and time to display in mm/dd/yyyy hh:mm:ss AM/PM format in textbox Mark as Not AnswerMark as Answer... Reply Contact Simply change the formula to: concat(field1, 'T', field2) Then you can use the formatting options to show it the way you like. Jimmy Rishe / Software Developer / Microsoft MVPQdabra Software 01-04-2012 08:08 AM In reply to venkatzeus Joined on 12-30-2010 Posts 46 Re: set date and time to display in mm/dd/yyyy hh:mm:ss AM/PM format in textbox Mark as Not AnswerMark as Answer... Reply Contact Hi,Tried like this:concat(substring(xdDate:Today(), 6, 2), "/", substring(xdDate:Today(), 9, 2), "/", substring(xdDate:Today(), 1, 4), " ", substring-after(xdDate:Now(), "T")) and it is giving result.However, AM/PM is not shown.. Is it possible to add the AM/PM with the above formula. Thank you 01-04-2012 08:19 AM In reply to Jimmy Joined on 07-03-2008 Posts 2,595 Re: set date and time to display in mm/dd/yyyy hh:mm:ss AM/PM format in textbox Mark as Not AnswerMark as Answer... Reply Contact Why not just have the default value as now(), and use the formatting options to display it the way you want it? Jimmy Rishe / Software Developer / Microsoft MVPQdabra Software 01-04-2012 08:41 PM In reply to venkatzeus Joined on 12-30-2010 Posts 46 Re: set date and time to display in mm/dd/yyyy hh:mm:ss AM/PM format in textbox Mark as Not AnswerMark as Answer... Reply Contact Hi,Thank you very much for the reply.Data type of the textbox is text(string)Could you please provide the format code for using with now() to show in mm/dd/yyyy hh:mm:ss AM/PM format. Thank you 01-04-2012 10:16 PM In reply to Jimmy Joined on 07-03-2008 Posts 2,595 Re: set date and time to display in mm/dd/yyyy hh:mm:ss AM/PM format in textbox Mark as Not AnswerMark as Answer... Reply Contact Well, this is the formula I came up with based on your original question: concat(substring(field1, 6, 2), "/", substring(field1, 9, 2), "/", substring(field1, 1, 4), " ", substring("0", 1, substring(field2, 1, 2) mod 12 + 12 * (substring(field2, 1, 2) mod 12 = 0) < 10), substring(field2, 1, 2) mod 12 + 12 * (substring(field2, 1, 2) mod 12 = 0), substring(field2, 3, 6), " ", substring("AP", 1 + (substring(field2, 1, 2) >= 12), 1), "M") Why can't you change the data type of the field? Jimmy Rishe / Software Developer / Microsoft MVPQdabra Software Page 1 of 1 (6 items) Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.
Hi,
I have added 3 textboxes.
one having date only. Another having time only.
In the third textbox, i would like to have the concatenated value.
First textbox - Data type as Date - shows result as : 01/04/2012
Second textbox - Data type as Time - shows result as : 06:57:11 AM ( i used this formula: substring-after(now(), "T") )
Third textbox - Data type as Text(string). I have added the rule for concatenating as : concat(field1, field2)
However the Third textbox is displaying result as : 2012-01-0406:57:11
I need to show in the third textbox as : 01/04/2012 06:57:11 AM
How to achieve this?
Thank you
Simply change the formula to:
concat(field1, 'T', field2)
Then you can use the formatting options to show it the way you like.
Tried like this:
concat(substring(xdDate:Today(), 6, 2), "/", substring(xdDate:Today(), 9, 2), "/", substring(xdDate:Today(), 1, 4), " ", substring-after(xdDate:Now(), "T"))
and it is giving result.
However, AM/PM is not shown.. Is it possible to add the AM/PM with the above formula.
Why not just have the default value as now(), and use the formatting options to display it the way you want it?
Thank you very much for the reply.
Data type of the textbox is text(string)
Could you please provide the format code for using with now() to show in mm/dd/yyyy hh:mm:ss AM/PM format.
Well, this is the formula I came up with based on your original question:
concat(substring(field1, 6, 2), "/", substring(field1, 9, 2), "/", substring(field1, 1, 4), " ", substring("0", 1, substring(field2, 1, 2) mod 12 + 12 * (substring(field2, 1, 2) mod 12 = 0) < 10), substring(field2, 1, 2) mod 12 + 12 * (substring(field2, 1, 2) mod 12 = 0), substring(field2, 3, 6), " ", substring("AP", 1 + (substring(field2, 1, 2) >= 12), 1), "M")
Why can't you change the data type of the field?