How can I change the default date format?

I have formatted the date. But it increases another column. Is it possible to replace the default date format to my custom format (d/m/y)?

date%20format
date%20format-kobo

Nope. The format used to submit results to the server of type date is prescribed and fixed by the XForms specification. However you can convert to/from pretty much any custom format you desire using the format-date() function.

For example, to get something like “09/10/19” you can use:

format-date(${mydate}, '%d/%m/%y')

If you use this in a calculation, your calculation result will contain your date in your desired format when submitted to your server.

1 Like

Thanks a lot, @Xiphware. Do you show me how should I write? I have tried, but not working.

date-error

since you are reformating ${mydate} to a custom format, you need to put it in a new result, of type text; ie

type=text, name=mynewdate, calculation=format-date(${mydate}, '%d/%m/%y')

(${mydate} is type date, so you cannot reformat it in situ)

3 Likes

Hello,
just as side-note: You will loose a lot of functionality (like adaptable calendar widget, date calculations, date type in export, …) with the conversion to a text field.
In general, it may be preferable to keep with the standard options of KoBo (the tool used).
Kind regards
Wolfgang

2 Likes

05d/05m/22yyy: On downloading, the excel gives me this result.

I have used Type calculate and used this, format-date(${dob},’%d/%m/%y’)

Hello @Priyanka,
what do you mean with 22yyy here? Is this 22yy?
Your calculate creates a text variable which is exported as string. (It could then be transformed in Excel to a date, using an Excel date format)

1 Like

Yes. In my exported data it looks like this.
Added images for your reference.

Yes. In my exported data it looks like this.
Added images for your reference

Please guide me on the issue.

Hello @Priyanka,
there is a lot of previous discussion on date formatting and age calculation in this forum. The (always recommended) search function may help you, e.g. https://community.kobotoolbox.org/t/how-to-change-the-date-format-from-yyyy-mm-dd-to-dd-mm-yyyy/25258/2.

The table screenshot indicated there seem to be more problems in your form. So, you may provide, please, a form extract with all variables/calculations around your date issue.

Dear Wroos,

Thank you for the reply.

As suggested I am attaching a form extract for your perusal
aHQYcgkM4GwQt9JdsURSBA (9).xlsx (41.0 KB)
. Please let me know about ‘more problems’ you mentioned in the post above.