Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
4675 Zobrazení

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
Zrušit
Autor

thank you  @Ravi Gadhia 

Nejlepší odpověď

<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
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
0
čvc 21
2103
2
bře 24
2421
1
úno 23
2902
1
říj 21
7724
3
čvn 25
826