I have a date field in the form created using InfoPath, that allows the users to enter a date, which presumably is the due date of a task. And I want to have another "calculated value" field to:
- if the the date has passed, then show "overdue"
- if not, then show the number of days left till the given date
Is this possible without writing VB/C# code, but just pasting an expression into the XPath dialog box?
Thanks!
Assuming this is your xml node where user enters date value
<due-date>2012-02-08</due-date>
then below xpath expression will return the days remaining for the due-date if the date entered is before the current-date and returns 'OverDue' if the entered date passes current-date.
if((xs:date(current-date())) <= (xs:date(/due-date)))
then days-from-duration( (xs:date(/due-date)) - (xs:date(current-date())) )
else 'OverDue'