Hi Team,
Greetings of the day,
This is related to date field, is their any possibility of getting today’s date as default in the date field.
Could you please respond ASAP. Thanks
Regards,
Supriya
Hi Team,
Greetings of the day,
This is related to date field, is their any possibility of getting today’s date as default in the date field.
Could you please respond ASAP. Thanks
Regards,
Supriya
Hello,
you can use a workaround: calculate as once(today()).
Default doesn’t allow a calculation.
Kind regards
Hi @msupriya,
As outlined by @wroos you could also do it as shown in the image below using today()
under the calculation
and keeping the read_only
as TRUE
with the date
question type:
Or, using now()
under the calculation
and keeping the read_only
as TRUE
with the date
question type as shown in the image below:
Both the approaches will give you the same result as shown in the image below:
Data entry screen as seen in Enketo:
Reference xlsform: Using today()
Default Today’s Date.xlsx (9.5 KB)
Reference xlsform: Using now()
Default Today’s Date.xlsx (9.5 KB)
An alternative way is using the using the same calculation in a constraint. For this, please have a look at the workaround discussed previously:
Have a great day!
HI @msupriya
Just to emphasize, the use of once as indicated by @wroos allows the date to be picked and it will not change even if you reopened the form at a later date. On the other hand, if you only use today() or now() the question will change to the day and time the form is last opened and the questions browsed through. The use of the functionality “once” prevents this,
Stephane
This is highly appreciated!
Hint: As stephane noted, using today() function without once will update when you open/save the form. (This is different to the metadata today which doesn’t change.)