跳至內容
選單
此問題已被標幟
1 回覆
3493 瀏覽次數

I'm developing a payroll module, and i need to calculate the quantity of mondays between two dates.

I'm Venezuela, there's a salary rule name "Social Security" and the formula is: (((Wage * 12) / 52) * 0.04) * quantity of mondays between dates.


Is there a way to calculates how many mondays are between two dates?

頭像
捨棄
最佳答案

Hi,

Try this:

mondays = 0
while date< date2:
     if date.weekday() == 0:
         mondays +=1

     date += relativedelta.relativedelta( days=+1)

Best regards

頭像
捨棄
相關帖文 回覆 瀏覽次數 活動
1
5月 25
858
1
3月 25
1042
0
2月 25
1227
1
12月 24
1748
0
11月 24
108