Query Regarding date_format

How can i return date in format 2018/11/02 rather than in this format 2020-06-11.
Code regarding this conversion will be helpful.

Where do you want to return date?

In the field date_ which is date type field.

A Date field does not store any string. It stores a date instance only.

So how can i return date in format YY/MM/DD ?

But what do you mean by return? Where in the code? Please explain clearly what you want to achieve.

1 Like
date_ = fields.Date('Date', states=STATES_READONLY, depends=DEPENDS, required=True)

In above code i want to return the date in format YY/MM/DD, but in front end by default in the form 2020-06-12.
I want date to come in the form 2020/06/12.

The client format the date according to the user language.

1 Like

Sir the language I am using is python.

The client (tryton desktop or sao) shows the date instance as a string (“YYYY-MM-DD” or “YYYY/MM/DD” or whatever) depending the language configured by the end-user in the client (it is a User Preferences).

The “language” could be “french” (the date will be formatted as “%d.%m.%Y”) for example , or could be “Lithuanian” (and the date will be formatted as “%Y-%m-%d”)

The exact way a date instance is converted to a string is configured in ir.lang Model.

1 Like

go to “Administration > Localization > Languages”

Example using English:
tick “English” switch to form view.
Then you can change the Date format

1 Like