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

Let's use date_from field from hr.holidays.

How can you make a filter, to make it show only those records, which date_from field is in the same month as it is right now?

Basicly date_from.strftime('%Y-%m)==time.strftime('%Y-%m') is what I'm trying to accomplish. Tried domains:

domain="[(date_from.strftime('%Y-%m'),'=',time.strftime('%Y-%m'))]
domain="[('date_from'.strftime('%Y-%m'),'=',time.strftime('%Y-%m'))]

Neither worked. Also thought about making check in a range of dates e.g. time.strftime('%Y-%m-01')<=date_from<... and then I dont know how to find out whats the last date of a month nor get to add a month.

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

Hi Anti Nuga,

You can add current months record by adding domain like this,

domain="[('date_from','&gt;=',time.strftime('%%Y-%%m-01'))]"

Thanks

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

The dates can be bigger than this months... e.g. I don't want it show 2017-09-XX dates at the moment (Its 2017-08- right now)

Related Posts ตอบกลับ มุมมอง กิจกรรม
5
ก.ย. 20
12848
1
มี.ค. 15
5331
0
มี.ค. 15
4002
2
มี.ค. 15
7567
6
พ.ค. 24
71053