tags:

views:

65

answers:

2

I am new to Xforms and need help setting the default date in nodeset binding. I need to set the default date to be current date + 30 days. How do I do this?

A: 

Figured it out. In the binding, I set the default for the date to days-to-date(days-from-date(local-date()) + 30). But this does not set the time though. And my field is of type xs:datetime.

Purni
+1  A: 

If you want the result to be an xs:dateTime, then the following will do the trick:

current-dateTime() + xs:dayTimeDuration('P30D')
Alessandro Vernet
I still need the date to be current date + 30 days. And display it with the time. Your suggestion shows only current-dateTime() + the time.
Purni
@Purni, it looks like I misunderstood what you are looking for. My suggestion shows current time + 30 days. What is it that you are looking for?
Alessandro Vernet
@Alessandro, I have a date time picker on my xform of type xs:dateTime. In binding, I need to set the default for this field to be current date + 30 days. days-to-date(days-from-date(local-date()) + 30) does this. But the problem is it sets only the date and not the time. I need it to set the dateTime in ISO dateTime. format.
Purni
@Purni, OK, but doesn't initializing the node with `current-dateTime() + xs:dayTimeDuration('P30D')` do that? It will put in the node the current date-time + 30 days, in the ISO dateTime format.
Alessandro Vernet
@Alessandro - I tried that yesterday and got an error. I guess I had a typo. I tried it just now and that totally works! Thanks!
Purni
@Purni, great, I'm glad this helped.
Alessandro Vernet
@Alessandro, the solution you gave gives me the time with milliseconds. Could you please help by giving me the solution without the milliseconds?
Purni