# ODK 2.0: Calculations with 'now' function

**URL:** <https://forum.odk-x.org/t/odk-2-0-calculations-with-now-function/386>\
**Category:** Support\
**Created:** [October 23, 2018, 11:29am UTC](https://forum.odk-x.org/t/odk-2-0-calculations-with-now-function/386 "2018-10-23T11:29:22Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Satish\_Ravishankar](https://odkx.b-cdn.net/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@Satish\_Ravishankar](https://forum.odk-x.org/u/Satish_Ravishankar)\
**Post date:** [October 23, 2018, 11:29am UTC](https://forum.odk-x.org/t/odk-2-0-calculations-with-now-function/386/1 "2018-10-23T11:29:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![linl33](https://odkx.b-cdn.net/letter_avatar_proxy/v4/letter/l/b487fb/32.png) [@linl33](https://forum.odk-x.org/u/linl33)\
**Post date:** [October 23, 2018, 9:48pm UTC](https://forum.odk-x.org/t/odk-2-0-calculations-with-now-function/386/2 "2018-10-23T21:48:33Z")

</div>

Hi,

The reference for that function, and other functions, is available at [ODK-X XLSX Converter Reference — ODK-X Docs](https://docs.opendatakit.org/odk2/xlsx-converter-reference/#id21).

---

<div class="post-metadata">

**Author:** ![Satish\_Ravishankar](https://odkx.b-cdn.net/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@Satish\_Ravishankar](https://forum.odk-x.org/u/Satish_Ravishankar)\
**Post date:** [October 24, 2018, 4:32am UTC](https://forum.odk-x.org/t/odk-2-0-calculations-with-now-function/386/3 "2018-10-24T04:32:32Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Satish\_Ravishankar](https://odkx.b-cdn.net/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@Satish\_Ravishankar](https://forum.odk-x.org/u/Satish_Ravishankar)\
**Post date:** [October 25, 2018, 6:05am UTC](https://forum.odk-x.org/t/odk-2-0-calculations-with-now-function/386/4 "2018-10-25T06:05:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![linl33](https://odkx.b-cdn.net/letter_avatar_proxy/v4/letter/l/b487fb/32.png) [@linl33](https://forum.odk-x.org/u/linl33)\
**Post date:** [October 28, 2018, 7:42pm UTC](https://forum.odk-x.org/t/odk-2-0-calculations-with-now-function/386/5 "2018-10-28T19:42:12Z")

</div>

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

```js
data('born') && data('born').getDate() === now().getDate() && data('born').getMonth() === now().getMonth()

```
