why this expression places "NaN" in the output...

12 views
Skip to first unread message

Eric Stephan

unread,
Jul 2, 2014, 6:14:47 AM7/2/14
to commcar...@googlegroups.com

Hi all... here is a serious newbie question for you all --

I have the following expression in a label:

Days since last visit: <output value="int(today() - /data/loaded_date)"/>

I'm kind of wishing it would say something like 5 (if the number of days between the two were five) ...

for your info, "loaded date" is loaded into the form by means of case management...

and also, when I make label fields to simply display the contents of those two date fields, for debugging, they both display fine!

I'm sure it's just a thing about how you work with date expressions...  any thoughts?

thanks
eric

Devika .

unread,
Jul 2, 2014, 6:30:01 AM7/2/14
to commcar...@googlegroups.com
Hi Eric,

For calculations with dates, you have to convert the stored value into a date first. CommCare stores dates as strings that cannot be used for calculations. So your expression would be:
int ( today() - date(/data/loaded_date) )

Best,
Devika

Field Manager, Dimagi
Skype: d_devika



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

Eric Stephan

unread,
Jul 2, 2014, 10:40:10 PM7/2/14
to commcar...@googlegroups.com
 
Aha... I knew it would be something like that. Big thanks for your help. I will have to touch base with the reference materials again. THANKS --Eric
You received this message because you are subscribed to a topic in the Google Groups "commcare-users" group.
To unsubscribe from this group and all its topics, send an email to commcare-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages