Default Today's date

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

1 Like

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:

image

Or, using now() under the calculation and keeping the read_only as TRUE with the date question type as shown in the image below:
image

Both the approaches will give you the same result as shown in the image below:

Data entry screen as seen in Enketo:
image

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!

2 posts were split to a new topic: The same question behaving differently in Enketo & KoBoCollect android app

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

1 Like