Se rendre au contenu
Menu
Cette question a été signalée
2 Réponses
4693 Vues

i want to display only the year from request_date_from in a q-web report 

i tried this code 

 <span t-esc="datetime.datetime.strptime(o.request_date_from, '%Y-%m-%d').strftime('%Y')"/>

but i get this error 


Error to render compiling AST TypeError: strptime() argument 1 must be str, not datetime.date Template: mymodule.leave 
Path: /t/t/t/t/div/p/span
Node: <span t-esc="datetime.datetime.strptime(o.request_date_from, '%Y-%m-%d').strftime('%Y')"/>)
Avatar
Ignorer
Auteur

thank you  @Ravi Gadhia 

Meilleure réponse

<span t-field="o.request_date_from" t-options='{"format": "yyyy"}'/>

you can use any babel format http://babel.pocoo.org/en/latest/dates.html#date-fields

Avatar
Ignorer
Publications associées Réponses Vues Activité
0
juil. 21
2126
2
mars 24
2453
1
févr. 23
2927
1
oct. 21
7766
3
juin 25
864