简体   繁体   English

根据预定义的周长计算日期范围内的可计费天数

[英]Calculate billable days in date range based on predefined week length

I am attempting to devise a formula that will allow for the correct billing days based on a predefined week length. 我正在尝试设计一个公式,该公式将根据预定义的周长来提供正确的结算天数。 Take this example: 举个例子:

  • Qty: 5 数量:5
  • Price Per: $1 单价:$ 1
  • Date Start: 1/1/2017 开始日期:1/1/2017
  • Date End: 1/7/2017 结束日期:1/7/2017
  • Days Per Week: 3 每周天数:3
  • Total billed: $15 总费用: 15美元

Billing on a 3 day week would mean that 1-3 days would be billed on (Qty * Price Per) but days 4-7 are essentially free. 每周进行3天的计费,意味着需要1-3天(Qty * Price Per)计费,但第4-7天基本上是免费的。 This would have to work for long period also. 这也必须长期工作。

More Examples: 更多示例:

  • Qty: 5 数量:5
  • Price Per: $1 单价:$ 1
  • Date Start: 1/1/2017 开始日期:1/1/2017
  • Date End: 1/8/2017 结束日期:2017年1月8日
  • Days Per Week: 1 每周天数:1
  • Total billed: $10 总费用: 10美元

  • Qty: 5 数量:5
  • Price Per: $1 单价:$ 1
  • Date Start: 1/1/2017 开始日期:1/1/2017
  • Date End: 1/10/2017 结束日期:2017年1月10日
  • Days Per Week: 1 每周天数:1
  • Total billed: $10 Any help is greatly appreciated! 总计: $ 10如有任何帮助,我们将不胜感激!

Try this: 尝试这个:

=MIN(MOD(B4-B3+1,7),B5)*B1*B2+INT((B4-B3+1)/7)*B1*B2*B5

where: 哪里:

B1: Qty B1:数量

B2: Price Per B2:单价

B3: Date Start B3:日期开始

B4: Date End B4:日期结束

B5: Days per Week B5:每周天数

With this setup: 使用此设置:

在此处输入图片说明

Breaking it down: 分解:

  • lesser of number days left over after subtracting the whole weeks, or maximum number of days to count in a week MIN(MOD(B4-B3+1,7),B5) 减去整周后剩余的天数较少,或一周中要计算的最大天数MIN(MOD(B4-B3+1,7),B5)

    • multiply by Qty * Price Per 乘以Qty * Price Per
  • number of whole weeks INT((B4-B3+1)/7) 整周数INT((B4-B3+1)/7)

    • multiply by Qty * Price Per * Days in Week 乘以Qty * Price Per * Days in Week

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM