Skip to Content
Menu
This question has been flagged
1 Atsakyti
10951 Rodiniai

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

Portretas
Atmesti
Best Answer

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)))]" />

Portretas
Atmesti
Autorius

Excellent

thanks so much for your help :)

Related Posts Replies Rodiniai Veikla
2
saus. 23
13776
0
bal. 18
5581
0
kov. 15
5320
2
saus. 24
2590
2
birž. 22
4522