# [ODK Community] Relevant: date 2 is more than or equal to six months since date 1

Laura,

Don't think date subtractions work in ODK. Read through
https://groups.google.com/d/msg/opendatakit/um9g921Qu1c/nHjlkM2rVFEJ
for some workarounds.

Yaw

··· -- Need ODK services? http://nafundi.com provides form design, server setup, professional support, and software development for ODK.

On Mon, Mar 31, 2014 at 5:21 AM, laura@blueventures.org wrote:

Hi there,

I'm currently creating an ODK form in Excel and then using the XLSForm tool to convert it. I would be really grateful if anybody could advise me on how to specify that a question is only relevant if date 2 is more than or equal to six months since date 1:

Q1: What is the date of the current consultation? (Calendar)

Q2: What is the date of the client's last blood pressure check? (Calendar)

Q3: Check and record the client's blood pressure... (Relevant: only if Q2 is more than or equal to six months since Q1)

Thanks!

## --

You received this message because you are subscribed to the Google Groups "ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

There is now a function:

decimal-date-time(aDateTime)

that will return a decimal number that represents the date or date-time
value in a given field.

where 1 = 1 day

and:

date-time(aDecimalValue)

that should convert a decimal value back into a dateTime.

i.e., aDateTime = date-time(decimal-date-time(aDateTime))

So you could do:

date-time( decimal-date-time(\${startDateTime}) + 3 )

to get the day 3 days from the \${startDateTime} field

HOWEVER: due to internal quirks in the library, date and dateTime
arithmetic is often truncated such that the time portion of the field is
lost.

So your date arithmetic is likely to be broken or inaccurate when adding
hours or fractional days and could be off by up to 23 hours 59 minutes, 59
seconds.

But for 6 months, that should be good enough?

You can then add or

··· On Wed, Apr 2, 2014 at 12:48 PM, Yaw Anokwa wrote:

Laura,

Don't think date subtractions work in ODK. Read through
https://groups.google.com/d/msg/opendatakit/um9g921Qu1c/nHjlkM2rVFEJ
for some workarounds.

## Yaw

Need ODK services? http://nafundi.com provides form design, server
setup, professional support, and software development for ODK.

On Mon, Mar 31, 2014 at 5:21 AM, laura@blueventures.org wrote:

Hi there,

I'm currently creating an ODK form in Excel and then using the XLSForm
tool to convert it. I would be really grateful if anybody could advise me
on how to specify that a question is only relevant if date 2 is more than
or equal to six months since date 1:

Q1: What is the date of the current consultation? (Calendar)

Q2: What is the date of the client's last blood pressure check?
(Calendar)

Q3: Check and record the client's blood pressure... (Relevant: only if
Q2 is more than or equal to six months since Q1)

Thanks!

## --

You received this message because you are subscribed to the Google
Groups "ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

## --

You received this message because you are subscribed to the Google Groups
"ODK Community" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Mitch Sundt
Software Engineer
University of Washington
mitchellsundt@gmail.com