Set a text box the current date/time

N

NikV

I have a command button. After the user clicks on it I want to populate a
text box with a "CR" and the current date/time formated as mmyyhhmm. For
example, the resulting string would be CR01054505. Please help. Thanks!
 
G

Greg Collins [InfoPath MVP]

Although it is likely possible to do this with rules, it will be complicated. Best bet is to use code.

--
Greg Collins [InfoPath MVP]
Visit http://www.InfoPathDev.com


I have a command button. After the user clicks on it I want to populate a
text box with a "CR" and the current date/time formated as mmyyhhmm. For
example, the resulting string would be CR01054505. Please help. Thanks!
 
S

S.Y.M. Wong-A-Ton

The now() function returns the current system date and time in a format like
yyyy-mm-ddThh:mm:ss. So you can use this information to create a rule on the
button that sets the value of the text box using a formula like:

concat("CR", substring(now(), 6, 2), substring(now(), 3, 2),
substring(now(), 12, 2), substring(now(), 15, 2))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top