Calculate on date types

Hi all,

I'd like to display a field to the user:
Clinic information within 12 months of clinic enrolment (between and XXX)

I would the XXX to be ENRDT + 12 months.

I have tried using a calculate, eg
XXX =

but this is a bit of a shot in the dark (esp that + 12, heh).

There is probably also a cleaner way to do this (eg can I manipulate the content of an field?)

Suggestions are welcome, and thanks in advance,
Colin

There are various date-time functions available:

e.g., decimal-date().

Note, however, that there are numerous bugs/issues with date-time
arithmetic and getting the logic to respect and preserve the time portion
of the date-time.

Carefully test to ensure that what you write actually works.

··· On Fri, May 15, 2015 at 7:17 AM, wrote:

Hi all,

I'd like to display a field to the user:
Clinic information within 12 months of clinic enrolment (between and XXX)

I would the XXX to be ENRDT + 12 months.

I have tried using a calculate, eg
XXX =


but this is a bit of a shot in the dark (esp that + 12, heh).

There is probably also a cleaner way to do this (eg can I manipulate the
content of an field?)

Suggestions are welcome, and thanks in advance,
Colin

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

There are various date-time functions available: https://opendatakit.org/help/form-design/binding/

e.g., decimal-date().

Note, however, that there are numerous bugs/issues with date-time arithmetic and getting the logic to respect and preserve the time portion of the date-time.

Carefully test to ensure that what you write actually works.

Hi all,

I'd like to display a field to the user:

Clinic information within 12 months of clinic enrolment (between and XXX)

I would the XXX to be ENRDT + 12 months.

I have tried using a calculate, eg

XXX =

but this is a bit of a shot in the dark (esp that + 12, heh).

There is probably also a cleaner way to do this (eg can I manipulate the content of an field?)

Suggestions are welcome, and thanks in advance,

Colin

--

--

Post: opend...@googlegroups.com

Unsubscribe: opendatakit...@googlegroups.com

Options: http://groups.google.com/group/opendatakit?hl=en


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...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

Mitch Sundt
Software Engineer
University of Washington
mitche...@gmail.com

Durr... don't know how I missed that. Thanks Mitch

··· On Friday, May 15, 2015 at 12:58:27 PM UTC-4, Mitch Sundt wrote: > On Fri, May 15, 2015 at 7:17 AM, wrote:

There are various date-time functions available: https://opendatakit.org/help/form-design/binding/

e.g., decimal-date().

Note, however, that there are numerous bugs/issues with date-time arithmetic and getting the logic to respect and preserve the time portion of the date-time.

Carefully test to ensure that what you write actually works.

Hi,

I'm trying to write a simple formula to check whether occurs a date X occurs at least 3 months after date Y, and if not, return a warning message.

To do this I have created a note that only shows when this condition is not met.

I have tried this using an XLSForm that is then uploaded to KoboToolbox

Relevant field: decimal-date(${dateX}) - decimal-date(${dateY}) > '90'

I have also tried putting the constraint directly in the XML file to upload to ODK aggregate:

" decimal-date(dateX) - decimal-date(dateY) > '90'"

in both cases I receive the error: " XPath evaluation: cannot handle function 'decimal-date' "

This sounds like decimal-date isn't accepted at all as a function, though the previous post suggest it is/should be.

Would appreciate any thoughts on this

Thanks

Jan

··· On Friday, May 15, 2015 at 5:58:27 PM UTC+1, Mitch Sundt wrote:

On Fri, May 15, 2015 at 7:17 AM, colind...@gmail.com wrote:
Hi all,

I'd like to display a field to the user:

Clinic information within 12 months of clinic enrolment (between and XXX)

I would the XXX to be ENRDT + 12 months.

I have tried using a calculate, eg

XXX =

but this is a bit of a shot in the dark (esp that + 12, heh).

There is probably also a cleaner way to do this (eg can I manipulate the content of an field?)

Suggestions are welcome, and thanks in advance,

Colin

--

--

Post: opend...@googlegroups.com

Unsubscribe: opendatakit...@googlegroups.com

Options: http://groups.google.com/group/opendatakit?hl=en


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...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

Mitch Sundt
Software Engineer
University of Washington
mitche...@gmail.com

I was also unable to get decimal-date to work correctly.

However, I believe I have an approach that could work for your issue... you can perform basic math functions on date objects in ODK. That is, you can use div, -, etc (as well as > and <).

Snippet of my code:
constraint = ( (((. - /data/ENROLDT) div 365.25) >= 1)

So, extrapolating from that, you might try something like:
((${dateX} - ${dateY}) div 365.25) > 1/4
Or, more human readably
((${dateX} - ${dateY}) div 30) > 3

··· On Thursday, June 4, 2015 at 1:13:46 PM UTC-4, jan.p...@gmail.com wrote: > On Friday, May 15, 2015 at 5:58:27 PM UTC+1, Mitch Sundt wrote: > > There are various date-time functions available: https://opendatakit.org/help/form-design/binding/ > > > > e.g., decimal-date(). > > > > Note, however, that there are numerous bugs/issues with date-time arithmetic and getting the logic to respect and preserve the time portion of the date-time. > > > > Carefully test to ensure that what you write actually works. > > > > Hi, > > I'm trying to write a simple formula to check whether occurs a date X occurs at least 3 months after date Y, and if not, return a warning message. > > To do this I have created a note that only shows when this condition is not met. > > I have tried this using an XLSForm that is then uploaded to KoboToolbox > > Relevant field: decimal-date(${dateX}) - decimal-date(${dateY}) > '90' > > I have also tried putting the constraint directly in the XML file to upload to ODK aggregate: > > " decimal-date(dateX) - decimal-date(dateY) > '90'" > > in both cases I receive the error: " XPath evaluation: cannot handle function 'decimal-date' " > > This sounds like decimal-date isn't accepted at all as a function, though the previous post suggest it is/should be. > > Would appreciate any thoughts on this > > Thanks > > Jan > > > > > > > > > > > > > > > > > > On Fri, May 15, 2015 at 7:17 AM, wrote: > > Hi all, > > > > > > > > I'd like to display a field to the user: > > > > Clinic information within 12 months of clinic enrolment (between and XXX) > > > > > > > > I would the XXX to be ENRDT + 12 months. > > > > > > > > > > > > I have tried using a calculate, eg > > > > XXX = > > > > > > > > > > > > but this is a bit of a shot in the dark (esp that + 12, heh). > > > > > > > > There is probably also a cleaner way to do this (eg can I manipulate the content of an field?) > > > > > > > > Suggestions are welcome, and thanks in advance, > > > > Colin > > > > > > > > -- > > > > -- > > > > Post: opend...@googlegroups.com > > > > Unsubscribe: opendatakit...@googlegroups.com > > > > Options: http://groups.google.com/group/opendatakit?hl=en > > > > > > > > --- > > > > 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...@googlegroups.com. > > > > For more options, visit https://groups.google.com/d/optout. > > > > > > > > > > -- > > > > Mitch Sundt > > Software Engineer > > University of Washington > > mitche...@gmail.com

Oops. My mistake.

The name of the function is:

decimal-date-time()

there is no decimal-date() function.

··· On Thu, Jun 4, 2015 at 10:41 AM, wrote:

I was also unable to get decimal-date to work correctly.

However, I believe I have an approach that could work for your issue...
you can perform basic math functions on date objects in ODK. That is, you
can use div, -, etc (as well as > and <).

Snippet of my code:
constraint = ( (((. - /data/ENROLDT) div 365.25) >= 1)

So, extrapolating from that, you might try something like:
((${dateX} - ${dateY}) div 365.25) > 1/4
Or, more human readably
((${dateX} - ${dateY}) div 30) > 3

On Thursday, June 4, 2015 at 1:13:46 PM UTC-4, jan.p...@gmail.com wrote:

On Friday, May 15, 2015 at 5:58:27 PM UTC+1, Mitch Sundt wrote:

There are various date-time functions available:
https://opendatakit.org/help/form-design/binding/

e.g., decimal-date().

Note, however, that there are numerous bugs/issues with date-time
arithmetic and getting the logic to respect and preserve the time portion
of the date-time.

Carefully test to ensure that what you write actually works.

Hi,

I'm trying to write a simple formula to check whether occurs a date X
occurs at least 3 months after date Y, and if not, return a warning message.

To do this I have created a note that only shows when this condition is
not met.

I have tried this using an XLSForm that is then uploaded to KoboToolbox

Relevant field: decimal-date(${dateX}) - decimal-date(${dateY}) > '90'

I have also tried putting the constraint directly in the XML file to
upload to ODK aggregate:

" decimal-date(dateX) - decimal-date(dateY) > '90'"

in both cases I receive the error: " XPath evaluation: cannot handle
function 'decimal-date' "

This sounds like decimal-date isn't accepted at all as a function,
though the previous post suggest it is/should be.

Would appreciate any thoughts on this

Thanks

Jan

On Fri, May 15, 2015 at 7:17 AM, colind...@gmail.com wrote:
Hi all,

I'd like to display a field to the user:

Clinic information within 12 months of clinic enrolment (between
and XXX)

I would the XXX to be ENRDT + 12 months.

I have tried using a calculate, eg

XXX =

but this is a bit of a shot in the dark (esp that + 12, heh).

There is probably also a cleaner way to do this (eg can I manipulate
the content of an field?)

Suggestions are welcome, and thanks in advance,

Colin

--

--

Post: opend...@googlegroups.com

Unsubscribe: opendatakit...@googlegroups.com

Options: http://groups.google.com/group/opendatakit?hl=en


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...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

Mitch Sundt
Software Engineer
University of Washington
mitche...@gmail.com

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

Thanks both!

Mitch, no worries- I really should have just tried that myself.

Colin, thanks for the tip, I didn’t realise I could use dates in math functions without having to convert them first – problem solved!

··· From: opendatakit@googlegroups.com [mailto:opendatakit@googlegroups.com] On Behalf Of Mitch Sundt Sent: 04 June 2015 22:45 To: ODK Community Subject: Re: [ODK Community] Calculate on date types

Oops. My mistake.

The name of the function is:

decimal-date-time()

there is no decimal-date() function.

On Thu, Jun 4, 2015 at 10:41 AM, colindmccann@gmail.com wrote:

I was also unable to get decimal-date to work correctly.

However, I believe I have an approach that could work for your issue... you can perform basic math functions on date objects in ODK. That is, you can use div, -, etc (as well as > and <).

Snippet of my code:
constraint = ( (((. - /data/ENROLDT) div 365.25) >= 1)

So, extrapolating from that, you might try something like:
((${dateX} - ${dateY}) div 365.25) > 1/4
Or, more human readably
((${dateX} - ${dateY}) div 30) > 3

On Thursday, June 4, 2015 at 1:13:46 PM UTC-4, jan.p...@gmail.com wrote:

On Friday, May 15, 2015 at 5:58:27 PM UTC+1, Mitch Sundt wrote:

There are various date-time functions available: https://opendatakit.org/help/form-design/binding/

e.g., decimal-date().

Note, however, that there are numerous bugs/issues with date-time arithmetic and getting the logic to respect and preserve the time portion of the date-time.

Carefully test to ensure that what you write actually works.

Hi,

I'm trying to write a simple formula to check whether occurs a date X occurs at least 3 months after date Y, and if not, return a warning message.

To do this I have created a note that only shows when this condition is not met.

I have tried this using an XLSForm that is then uploaded to KoboToolbox

Relevant field: decimal-date(${dateX}) - decimal-date(${dateY}) > '90'

I have also tried putting the constraint directly in the XML file to upload to ODK aggregate:

" decimal-date(dateX) - decimal-date(dateY) > '90'"

in both cases I receive the error: " XPath evaluation: cannot handle function 'decimal-date' "

This sounds like decimal-date isn't accepted at all as a function, though the previous post suggest it is/should be.

Would appreciate any thoughts on this

Thanks

Jan

On Fri, May 15, 2015 at 7:17 AM, colind...@gmail.com wrote:
Hi all,

I'd like to display a field to the user:

Clinic information within 12 months of clinic enrolment (between and XXX)

I would the XXX to be ENRDT + 12 months.

I have tried using a calculate, eg

XXX =

but this is a bit of a shot in the dark (esp that + 12, heh).

There is probably also a cleaner way to do this (eg can I manipulate the content of an field?)

Suggestions are welcome, and thanks in advance,

Colin

--

--

Post: opend...@googlegroups.com

Unsubscribe: opendatakit...@googlegroups.com

Options: http://groups.google.com/group/opendatakit?hl=en


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...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

Mitch Sundt
Software Engineer
University of Washington
mitche...@gmail.com

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com mailto:opendatakit%2Bunsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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 mailto:opendatakit%2Bunsubscribe@googlegroups.com .
For more options, visit https://groups.google.com/d/optout.

--

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

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to a topic in the Google Groups "ODK Community" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/opendatakit/zwwIJ6oj0n0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

There is a lot of quirky behavior around dates, so be sure to test both the
success and error conditions to ensure that your form logic is actually
working.

··· On Fri, Jun 5, 2015 at 2:06 AM, Jan Priebe wrote:

Thanks both!

Mitch, no worries- I really should have just tried that myself.

Colin, thanks for the tip, I didn’t realise I could use dates in math
functions without having to convert them first – problem solved!

From: opendatakit@googlegroups.com [mailto:opendatakit@googlegroups.com]
*On Behalf Of *Mitch Sundt
Sent: 04 June 2015 22:45
To: ODK Community
Subject: Re: [ODK Community] Calculate on date types

Oops. My mistake.

The name of the function is:

decimal-date-time()

there is no decimal-date() function.

On Thu, Jun 4, 2015 at 10:41 AM, colindmccann@gmail.com wrote:

I was also unable to get decimal-date to work correctly.

However, I believe I have an approach that could work for your issue...
you can perform basic math functions on date objects in ODK. That is, you
can use div, -, etc (as well as > and <).

Snippet of my code:
constraint = ( (((. - /data/ENROLDT) div 365.25) >= 1)

So, extrapolating from that, you might try something like:
((${dateX} - ${dateY}) div 365.25) > 1/4
Or, more human readably
((${dateX} - ${dateY}) div 30) > 3

On Thursday, June 4, 2015 at 1:13:46 PM UTC-4, jan.p...@gmail.com wrote:

On Friday, May 15, 2015 at 5:58:27 PM UTC+1, Mitch Sundt wrote:

There are various date-time functions available:
https://opendatakit.org/help/form-design/binding/

e.g., decimal-date().

Note, however, that there are numerous bugs/issues with date-time
arithmetic and getting the logic to respect and preserve the time portion
of the date-time.

Carefully test to ensure that what you write actually works.

Hi,

I'm trying to write a simple formula to check whether occurs a date X
occurs at least 3 months after date Y, and if not, return a warning message.

To do this I have created a note that only shows when this condition is
not met.

I have tried this using an XLSForm that is then uploaded to KoboToolbox

Relevant field: decimal-date(${dateX}) - decimal-date(${dateY}) > '90'

I have also tried putting the constraint directly in the XML file to
upload to ODK aggregate:

" decimal-date(dateX) - decimal-date(dateY) > '90'"

in both cases I receive the error: " XPath evaluation: cannot handle
function 'decimal-date' "

This sounds like decimal-date isn't accepted at all as a function,
though the previous post suggest it is/should be.

Would appreciate any thoughts on this

Thanks

Jan

On Fri, May 15, 2015 at 7:17 AM, colind...@gmail.com wrote:
Hi all,

I'd like to display a field to the user:

Clinic information within 12 months of clinic enrolment (between
and XXX)

I would the XXX to be ENRDT + 12 months.

I have tried using a calculate, eg

XXX =

but this is a bit of a shot in the dark (esp that + 12, heh).

There is probably also a cleaner way to do this (eg can I manipulate
the content of an field?)

Suggestions are welcome, and thanks in advance,

Colin

--

--

Post: opend...@googlegroups.com

Unsubscribe: opendatakit...@googlegroups.com

Options: http://groups.google.com/group/opendatakit?hl=en


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...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--

Mitch Sundt
Software Engineer
University of Washington
mitche...@gmail.com

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


You received this message because you are subscribed to a topic in the
Google Groups "ODK Community" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/opendatakit/zwwIJ6oj0n0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
opendatakit+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

Post: opendatakit@googlegroups.com
Unsubscribe: opendatakit+unsubscribe@googlegroups.com
Options: http://groups.google.com/group/opendatakit?hl=en


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