使用工作日设置截止日期

时间:2019-05-29 16:12:39

标签: crystal-reports

我正在尝试根据收到的日期加上特定的天数来设置工作日,这取决于特定的测试,但是不确定如何在if / else if / else中使用while循环。所有尝试均导致Crystal显示错误,表明初始if之后的所有内容都不在公式中。该代码的主要结构来自https://kenhamady.com/formulas/form17.shtml

torch.nn.Max

1 个答案:

答案 0 :(得分:0)

尝试一下:

WhileReadingRecords;
DateVar Array Holidays;
DateVar Target:=Date({DATE_RECEIVED}); 
NumberVar Add; 
NumberVar Added := 0;

if {METADATA_REPOSITORY.FIELD_VARCHAR_16} = "Test_1" then

    NumberVar Add := 28;
    WHILE Added < Add
    Do (target := target +1;
        if dayofweek (target) in 2 to 6 and not (target in holidays)
            then Added:=Added+1
            else Added:=Added);
        Target;

//else 
if {ORDTASK.TESTGROUPNAME} = "Test_2" then

    NumberVar Add :=14;
    WHILE Added < Add
    Do (target := target +1;
        if dayofweek (target) in 2 to 6 and not (target in holidays)
            then Added:=Added+1
            else Added:=Added);
        Target;

//else 

    NumberVar Add := DateAdd("d", Tonumber({TESTS.DURATION}), {CENTRALRECEIVING.DATE_RECEIVED});
    WHILE Added < Add
    Do (target := target +1;
        if dayofweek (target) in 2 to 6 and not (target in holidays)
            then Added:=Added+1
            else Added:=Added);
        Target