特定范围的上个月的日期

Dates from the last month of specific ranges

如何将上个月的数据提取为三个部分?我可以使用函数 LASTMONTH 但这给了我整个月的时间。

我需要把它分成三个部分:

1st - 10th of last month
11th - 20th of last month
21st to end of last month

听起来像是两步问题:

  1. 编写一个公式,根据日期得出 3 个值
  2. 根据该公式对数据进行分组和排序

相关公式如下所示:

IF {yourDate} in date(year(currentdate),month(currentdate)-1, 1) to date(year(currentdate),month(currentdate)-1, 10)
THEN "A"
ELSE IF {yourDate} in date(year(currentdate),month(currentdate)-1, 11) to date(year(currentdate),month(currentdate)-1, 20)
THEN "B"
ELSE IF {yourDate} in date(year(currentdate),month(currentdate)-1, 21) to date(year(currentdate),month(currentdate),1)-1
THEN "C"
ELSE "D"

其中A、B、C为有效日期,D均为无效日期。酌情替换。