I already posted about how to set a date field in infopath by code behind. If you like to read this post, just look at this post. But this post i am gonna explain how to set the date field correctly by just using rules or the formula.
So we should look at first at the anatomy of the date. Mostly you know the date as
or whatelse. It does not matter. You have your date field and set the format as you like. But you can see that infopath saves the date always in this way:
yyyy-mm-ddThh:mm:ss – example: 2012-11-18T12:00:00
If you know that, you are able to use formulas to fill a date field with correct dates. So you have to use a “T” as separator between the date and the time.
In my example i provide dropdowns to choose a birthday. You have three dropdowns and the date field is normally hidden but in this case i left it visible to show you the result. On the datefield i added a a formula to the standard / default value, but you could also use a rule which runs if all three dropwdowns are filled or changed. I set the datefield with a concate(field1;”-“;field2;”-“;field3;”T00:00:00”;) and it works as you can see in the picture below. You should remember that field 1 = year, field 2 = month and field 3 = day. Otherwise field validation will fail.
..:: I LIKE SHAREPOINT ::..The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.