Changing the default date in a date question

When a date question is added to a form its default date is todays date.
I've been having problems setting this default date to a future date, ie. 3
months into the future.

date(/data/sale_date + 180) is what Ive tried to enter but it hasnt
worked so far. What should I enter?
Where should I put the value? In Advanced > Default Data Value or one of
the other fields?

Top of my mind, I think you have to cast the date to an int. It may be :

date(int(/data/sale_date) + 180)

No tried, not tested.

··· On 20/08/2014 14:17, bmcdonald@proximitydesigns.org wrote: > When a date question is added to a form its default date is todays date. > I've been having problems setting this default date to a future date, > ie. 3 months into the future. > > /date(/data/sale_date + 180)/ is what Ive tried to enter but it hasnt > worked so far. What should I enter? > Where should I put the value? In /Advanced > Default Data Value/ or one > of the other fields? > > > > > > -- > 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.

--
Charles Flèche
mHealth advisor
Télécoms Sans Frontières http://www.tsfi.org
Première Urgence - Aide Médicale Internationale http://www.pu-ami.org
+95 9 431 978 25
Skype: charles.fleche

Hi,

The default Data Value field in advanced is the right field to set the
default value of a question. However, you can only set it to a value, not
to a logical or mathematical expression. So you could set it to be a
specific date, but not to the value of another question as you are trying
to do.

You can use case properties to set the default value of a question, so if
you are able to save sale_date as a case property you could do the
following:

  1. In the form where you ask for sale_date, create a hidden value to
    calculate sale_date + 3 months
  2. save this to the case (e.g. as the case property
    sale_date_plus_three_months)
  3. Load sale_date_plus_three_months directly into the question whose
    default value you want to set.

Hope this helps!

Thanks,
Amelia

··· On Wed, Aug 20, 2014 at 3:56 AM, Charles Flèche wrote:

Top of my mind, I think you have to cast the date to an int. It may be :

date(int(/data/sale_date) + 180)

No tried, not tested.

On 20/08/2014 14:17, bmcdonald@proximitydesigns.org wrote:

When a date question is added to a form its default date is todays date.
I've been having problems setting this default date to a future date,
ie. 3 months into the future.

/date(/data/sale_date + 180)/ is what Ive tried to enter but it hasnt

worked so far. What should I enter?
Where should I put the value? In /Advanced > Default Data Value/ or one

of the other fields?

--
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
mailto:commcare-users+unsubscribe@googlegroups.com.

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

--
Charles Flèche
mHealth advisor
Télécoms Sans Frontières http://www.tsfi.org
Première Urgence - Aide Médicale Internationale http://www.pu-ami.org
+95 9 431 978 25
Skype: charles.fleche

--
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.

Thanks Amelia

··· On Wednesday, August 20, 2014 9:58:38 PM UTC+6:30, Amelia Sagoff wrote: > > Hi, > > The default Data Value field in advanced is the right field to set the > default value of a question. However, you can only set it to a value, not > to a logical or mathematical expression. So you could set it to be a > specific date, but not to the value of another question as you are trying > to do. > > You can use case properties to set the default value of a question, so if > you are able to save sale_date as a case property you could do the > following: > 1) In the form where you ask for sale_date, create a hidden value to > calculate sale_date + 3 months > 2) save this to the case (e.g. as the case property > sale_date_plus_three_months) > 3) Load sale_date_plus_three_months directly into the question whose > default value you want to set. > > Hope this helps! > > Thanks, > Amelia > > > On Wed, Aug 20, 2014 at 3:56 AM, Charles Flèche <mhealth...@tsfi.org > wrote: > >> Top of my mind, I think you have to cast the date to an int. It may be : >> >> date(int(/data/sale_date) + 180) >> >> >> No tried, not tested. >> >> >> >> >> >> On 20/08/2014 14:17, bmcd...@proximitydesigns.org wrote: >> >>> When a date question is added to a form its default date is todays date. >>> I've been having problems setting this default date to a future date, >>> ie. 3 months into the future. >>> >>> /date(/data/sale_date + 180)/ is what Ive tried to enter but it hasnt >>> >>> worked so far. What should I enter? >>> Where should I put the value? In /Advanced > Default Data Value/ or one >>> >>> of the other fields? >>> >>> >>> >>> >>> >>> -- >>> 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 >>> <mailto:commcare-users+unsubscribe@googlegroups.com >. >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> -- >> Charles Flèche >> mHealth advisor >> Télécoms Sans Frontières http://www.tsfi.org >> Première Urgence - Aide Médicale Internationale http://www.pu-ami.org >> +95 9 431 978 25 >> Skype: charles.fleche >> >> >> -- >> 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. >> > >