Why this expression places "NaN" in the output

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

I have the following expression in a label:

Days since last visit:

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

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
+91 9555571141

··· On Wed, Jul 2, 2014 at 3:44 PM, Eric Stephan wrote:

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

I have the following expression in a label:

Days since last visit:

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

--
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-users+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

··· On Wed, Jul 2, 2014, at 05:29 PM, Devika . wrote:

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
+91 9555571141

On Wed, Jul 2, 2014 at 3:44 PM, Eric Stephan <[1]estephan500@gmail.com> wrote:

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

I have the following expression in a label:

Days since last visit:

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

--

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
[2]commcare-users+unsubscribe@googlegroups.com.

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

--

You received this message because you are subscribed to a topic
in the Google Groups "commcare-users" group.

To unsubscribe from this topic, visit
[4]https://groups.google.com/d/topic/commcare-users/6jY9Yow6274
/unsubscribe.

To unsubscribe from this group and all its topics, send an
email to [5]commcare-users+unsubscribe@googlegroups.com.

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

References

  1. mailto:estephan500@gmail.com
  2. mailto:commcare-users+unsubscribe@googlegroups.com
  3. https://groups.google.com/d/optout
  4. https://groups.google.com/d/topic/commcare-users/6jY9Yow6274/unsubscribe
  5. mailto:commcare-users+unsubscribe@googlegroups.com
  6. https://groups.google.com/d/optout