achraf
achraf

Reputation: 69

can i increment date using xpath?

i need to increment current date by 7 days and i'm wondering if it's possible to do that using a xpath function.

thanks !!

Upvotes: 4

Views: 6325

Answers (2)

geoffc
geoffc

Reputation: 4100

If your date is in some numeric format (CTIME, seconds since 1970 (32 bit int), or FILETIME, 100 nanosecond counts since 1601 (64 bit)) then incrementing time is easy. Just add the correct number of seconds (or 100 nanosecond intervals) to the time.

You could convert your format to CTIME via the Java time function library, add the correct number of seconds (86,400 seconds in a day), and then convert it back to your string format, I suppose. Probably not the worlds most efficient approach though.

Upvotes: 0

Mads Hansen
Mads Hansen

Reputation: 66723

It is possible in XPATH 2.0. There are a number of date functions.

current-date() + xs:dayTimeDuration('P7D')

Upvotes: 6

Related Questions