InfoPath Date Display

Q: While working on an InfoPath form the other day, I created a text box for the sole purpose of displaying date/time. When I set the text of the field to Now(), the date appeared as "2005-10-21T13:48:51".

A: To get rid of the "T" in the middle and make the date more readable, I changed the data field type of the text box from Text to Date/Time. The date then appeared as "10/21/2005 1:48:51 PM".


EricRi said…
That's right - InfoPath does some default auto-formatting based on the type of the element.

Note that now() is a date + time and today() is just a date (good for just a date element).

While you could take a text node and force it to format as a date, note that since it's a text node, whatever the user types is going to be put back into the element directly, and then the date formatting code will be confused.

The strange "T" format you see above is known as ISO 8601, which is how dates and times are stored in the XML data for the form.

== Eric.

Popular posts from this blog

Working with double quotes (") in VB.Net

Using VB Script to display part of an IP address

The identifier that starts with "SELECT * FROM ...." is too long. Maximum length is 128.