Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
10991 มุมมอง

how convert a datetime field and compare with current date?

hi

I want to write a search view and define a filter in it, that compare "created_date" with "current date" and show all of requests that created today.

problem1: how write filter that get only date from "create_date" (because this field is datetime format)

problem2: how compare with current date?

<record id="support_services_view_search" model="ir.ui.view">

....

<filter name="today" string="Today" domain="[('??(how get date)???create_date','=',???]"/>


thanks

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi,

You can use the below:


<filter string="Today" domain="[('datetime_field', '&gt;=', datetime.datetime.combine(context_today(), datetime.time(0,0,0))),
('datetimefield', '&lt;=', datetime.datetime.combine(context_today(), datetime.time(23,59,59)))]" />

อวตาร
ละทิ้ง
ผู้เขียน

Excellent

thanks so much for your help :)

Related Posts ตอบกลับ มุมมอง กิจกรรม
2
ม.ค. 23
13831
0
เม.ย. 18
5607
0
มี.ค. 15
5334
2
ม.ค. 24
2618
2
มิ.ย. 22
4554