跳至內容
選單
此問題已被標幟
2 回覆
4695 瀏覽次數

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')"/>)
頭像
捨棄
作者

thank you  @Ravi Gadhia 

最佳答案

<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

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
0
7月 21
2128
2
3月 24
2458
1
2月 23
2927
1
10月 21
7768
3
6月 25
868