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

Hi,

I have been searching everywhere for this answer, but with no luck.

I want to use payslip.date_to.days to get the INT value from the date, to use in a condition for a rule.

I can do it like this:

date_to = str(payslip.date_to)[8:10]

if int(date_to) > 15:

    result = True


And it works! But I was told that is not the correct way to do it "pythonically".

Best way would be simply:

if payslip.date_to.days > 15:
    result = True

But all I get is Wrong python code defined for salary rule.

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

Hi Denisse,
only remove the "s" from day:


if payslip.date_to.day > 15:
    result = True


and it will work fine :)

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
1
ม.ค. 19
4665
4
ก.ย. 25
6323
0
มี.ค. 23
2424
0
ก.ค. 19
4634
0
ธ.ค. 18
3111