Skip to Content
Menu
This question has been flagged
2 Replies
3698 Views

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
Discard
Author

thank you  @Ravi Gadhia 

Best Answer

<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
Discard
Related Posts Replies Views Activity
0
Jul 21
1369
2
Mar 24
866
1
Feb 23
2117
1
Oct 21
6007
4
May 24
10068