ODK 2.0: Calculations with 'now' function

Can anyone detail the use of the ‘now’ function?

My plan is to use this function to generate a list of previous 6 months based on current month. This list/array should then be presented as the list of choices in a choose_multiple prompt.

A working example of this would be very helpful.

I’m using ODK 2.0 and Application Designer 2.1.0.

Hi,

The reference for that function, and other functions, is available at https://docs.opendatakit.org/odk2/xlsx-converter-reference/#id21.

Hi Lin,

Thanks for your response.

I have tried using it as given in the reference sheet - now().getDay() and now().
I tried assigning the returned value using an assign type so I can then perform calculations on that value to generate a list of months. This form does not load when I choose it from the main menu (page with list of surveys) and cycles me back to the main menu.

I considered the possibility that I may not be handling the returned value correctly. The JavaScript now method returns milliseconds, an integer. So I’m still unsure as to why using the now function would prevent the form from loading.

Thanks for your time, Lin!

Hey everyone,

Just checking in again.
I’m still unable to find a solution to this or understand the problem. I’ve only managed to identify the source as the now function.

A working example of the use of the now function would be very helpful.

Thanks for your time.

You can find an example of the now() function in the exampleForm form, survey sheet, cell D27.

data('born') && data('born').getDate() === now().getDate() && data('born').getMonth() === now().getMonth()
2 Likes