x页问题:计算工作日错误

x pages Question: calculate working day Error

我尝试使用计算域来计算休假和工作日。报错形式如下

计算工作日的脚本

var nDateStart = session.createDateTime(document1.getValue("StartDate")).toJavaDate();
var nDateEnd = session.createDateTime(document1.getValue("EndDate")).toJavaDate();

var syear = @Year(nDateStart)
var smth =  @Month(nDateStart)
var sday = @Day(nDateStart)
var startdate = @Date(syear,smth,sday)

var eyear = @Year(nDateEnd)
var emth =  @Month(nDateEnd)
var eday = @Day(nDateEnd)
var enddate = @Date(eyear,emth,eday)

var weekends = "1:7"; //assuming your weekend is Saturday and Sunday
var holidays = "@Date(2019;8;12):@Date(2019;12;25)"; // assuming your holiday is 12 August and 25th December
var formula = "@BusinessDays(" + startdate + ";" + enddate + ";" + weekends + ";" + holidays + ")";
return session.evaluate(formula);

您需要先计算出一个有效的公式,然后才能将其提交给 session.evaluate。您提交的字符串不是有效的公式。例如,您的参数只是一个未加引号的字符串。 删除开始日期和结束日期并将其替换为 ”@Date(“+syear+”;”+smonth+”;”+”;”+sday+”)” 之类的内容,它应该可以为您提供所需的公式。

Date/time Lotus 公式语言中的常量用方括号括起来,在documentation for @BusinessDays 中可以清楚地看到。试试这个:

var formula = "@BusinessDays([" + startdate + "];[" + enddate + "];" + weekends + ";[" + holidays + "])";
return session.evaluate(formula);