Auto computing dates in ODK

Greetings from the Philippines !

I have been using ODK Collect to design a form that collects date of supply
replenishment of specific health commodities. By rule, the commodities
should be replenished six weeks from the last re-supply date. I wish to
inquire a way on how to display the next replenishment date in the form
based on the re-supply date entered.

Thank you very much!

··· -- Alison O. Perez Software Developer Wireless Access for Health (WAH) Province of Tarlac, Philippines

Linkedin Profile: ph.linkedin.com/pub/alison-perez/56/44/a65/
Personal Blog: http://darthblitzkrieg.blogspot.com
ICT4D/H Blog: http://alisonperez.tk
Skype / IM: darth_ali

"Daring ideas are like chessmen moved forward; they may be beaten, but they
may start a winning game." -- Johann Wolfgang Goethe*

Hey Alison,

I don't think there is an easy way to do that. You can probably use a
combination of substring() and date() (see
http://opendatakit.org/help/form-design/binding) to approximate six
weeks, but it's going to be pretty messy. This code snippet for
estimating ages might help. http://pastie.org/2813174

The right way to do this is for an intrepid developer to add
days-from-date() and days-to-date() to JavaROSA's XForm engine. File
the feature request at https://bitbucket.org/javarosa/javarosa/issues
if you'd like to see it added by such a developer.

Yaw

··· On Thu, Aug 15, 2013 at 8:42 PM, Alison Perez wrote: > Greetings from the Philippines ! > > I have been using ODK Collect to design a form that collects date of supply > replenishment of specific health commodities. By rule, the commodities > should be replenished six weeks from the last re-supply date. I wish to > inquire a way on how to display the next replenishment date in the form > based on the re-supply date entered. > > Thank you very much! > > -- > Alison O. Perez > Software Developer > Wireless Access for Health (WAH) > Province of Tarlac, Philippines > > Linkedin Profile: ph.linkedin.com/pub/alison-perez/56/44/a65/ > Personal Blog: http://darthblitzkrieg.blogspot.com > ICT4D/H Blog: http://alisonperez.tk > Skype / IM: darth_ali > > "Daring ideas are like chessmen moved forward; they may be beaten, but they > may start a winning game." -- Johann Wolfgang Goethe* > > -- > -- > 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/groups/opt_out.

This functionality was added to ODK Collect 1.4 -- that release is not yet
pushed to Google Play - available on our downloads page
http://code.google.com/p/opendatakit/downloads/list

With that version, you can write a calculation for a dateTime type:

date-time(decimal-date-time(now()) + 42)

which would yield a dateTime that is 42 days into the future.

When doing date arithmetic like this, there are numerous inconsistencies
with the preservation of the time-of-day during this arithmetic. But it
sounds like you don't necessarily care about the time of day, just the date
of the future appointment.

Other functions for working with dates are described in the ODK Collect
release notes: http://code.google.com/p/opendatakit/wiki/CollectReleaseNotes

Mitch

··· On Fri, Aug 16, 2013 at 3:57 PM, Yaw Anokwa wrote:

Hey Alison,

I don't think there is an easy way to do that. You can probably use a
combination of substring() and date() (see
http://opendatakit.org/help/form-design/binding) to approximate six
weeks, but it's going to be pretty messy. This code snippet for
estimating ages might help. http://pastie.org/2813174

The right way to do this is for an intrepid developer to add
days-from-date() and days-to-date() to JavaROSA's XForm engine. File
the feature request at https://bitbucket.org/javarosa/javarosa/issues
if you'd like to see it added by such a developer.

Yaw

On Thu, Aug 15, 2013 at 8:42 PM, Alison Perez perez.alison@gmail.com wrote:

Greetings from the Philippines !

I have been using ODK Collect to design a form that collects date of
supply
replenishment of specific health commodities. By rule, the commodities
should be replenished six weeks from the last re-supply date. I wish to
inquire a way on how to display the next replenishment date in the form
based on the re-supply date entered.

Thank you very much!

--
Alison O. Perez
Software Developer
Wireless Access for Health (WAH)
Province of Tarlac, Philippines

Linkedin Profile: ph.linkedin.com/pub/alison-perez/56/44/a65/
Personal Blog: http://darthblitzkrieg.blogspot.com
ICT4D/H Blog: http://alisonperez.tk
Skype / IM: darth_ali

"Daring ideas are like chessmen moved forward; they may be beaten, but
they
may start a winning game." -- Johann Wolfgang Goethe*

--

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/groups/opt_out.

--

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/groups/opt_out.

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