根据下一个星期日至2个月结束时的记录选择

时间:2018-11-16 14:21:15

标签: crystal-reports

我想从{@Calc Promise Date}字段中提取日期范围为下周日到下个月末的所有记录。我已经在下个月的部分结束了,并使用此站点上的一些类似示例尝试了下一个星期日的部分,但是在下一个星期日的部分我仍然没有达到目标。

最初的尝试将从今天开始5天:

{@Calc Promise Date}>=DateSerial(Year(currentdate),Month(currentdate),Day(currentdate)+5)
and {@Calc Promise Date}<DateSerial(Year(currentdate),Month(currentdate)+2,1)

这是从提供给另一个用户的帮助中修改的,但是没有介绍如何将范围的开始日期调整为下一个星期日。

我尝试了以下操作,但由于我不了解正确的布局,或者如果这样做有助于获得所需的开始日期而出现错误。

{@Calc Promise Date} >= if DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),1),1) = 1
then DateSerial(Year(currentdate),Month(currentdate),1+7)
else if DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),1),1) = 2
then DateSerial(Year(currentdate),Month(currentdate),1+6)
else if DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),1),1) = 3     
then DateSerial(Year(currentdate),Month(currentdate),1+5)
else if DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),1),1) = 4    
then DateSerial(Year(currentdate),Month(currentdate),1+4)
else if DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),1),1) = 5     
then DateSerial(Year(currentdate),Month(currentdate),1+3)
else if DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),1),1) = 6     
then DateSerial(Year(currentdate),Month(currentdate),1+2)
else if DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),1),1) = 7    
then DateSerial(Year(currentdate),Month(currentdate),1+1)
and {@Calc Promise Date}<DateSerial(Year(currentdate),Month(currentdate)+2,1)

1 个答案:

答案 0 :(得分:0)

据我所知,您在Record Selection中编写此公式几乎完成了工作,而是创建了简单的公式并在记录选择中写了衬纸。

创建公式开始日期

if DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),1),1) = 1
then DateSerial(Year(currentdate),Month(currentdate),1+7)
else if DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),1),1) = 2
then DateSerial(Year(currentdate),Month(currentdate),1+6)
else if DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),1),1) = 3     
then DateSerial(Year(currentdate),Month(currentdate),1+5)
else if DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),1),1) = 4    
then DateSerial(Year(currentdate),Month(currentdate),1+4)
else if DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),1),1) = 5     
then DateSerial(Year(currentdate),Month(currentdate),1+3)
else if DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),1),1) = 6     
then DateSerial(Year(currentdate),Month(currentdate),1+2)
else if DayOfWeek(DateSerial(Year(currentdate),Month(currentdate),1),1) = 7    
then DateSerial(Year(currentdate),Month(currentdate),1+1)
and {@Calc Promise Date}<DateSerial(Year(currentdate),Month(currentdate)+2,1)

创建公式结束日期

DateSerial(Year(currentdate),Month(currentdate)+2,1)

现在选择记录:

{@Calc Promise Date}>={@Start Date}
and {@Calc Promise Date}<{@End Date}