set date and time to display in mm/dd/yyyy hh:mm:ss AM/PM format in textbox - InfoPath Dev
in

InfoPath Dev

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: Previous Next
  • 01-04-2012 07:18 AM

    set date and time to display in mm/dd/yyyy hh:mm:ss AM/PM format in textbox

    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

    Re: set date and time to display in mm/dd/yyyy hh:mm:ss AM/PM format in textbox

    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 MVP
    Qdabra Software
  • 01-04-2012 08:08 AM In reply to

    Re: set date and time to display in mm/dd/yyyy hh:mm:ss AM/PM format in textbox

     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

    Re: set date and time to display in mm/dd/yyyy hh:mm:ss AM/PM format in textbox

    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 MVP
    Qdabra Software
  • 01-04-2012 08:41 PM In reply to

    Re: set date and time to display in mm/dd/yyyy hh:mm:ss AM/PM format in textbox

     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

    Re: set date and time to display in mm/dd/yyyy hh:mm:ss AM/PM format in textbox

    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 MVP
    Qdabra Software
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.