콘텐츠로 건너뛰기
메뉴
신고된 질문입니다
1 회신
4269 화면

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 :)

아바타
취소
관련 게시물 답글 화면 활동
1
1월 19
4667
4
9월 25
6324
0
3월 23
2426
0
7월 19
4634
0
12월 18
3111