Add number to date field using SIL Script

Krithica Gowri Shankar February 14, 2018

Hi,

I have a date field say customfield_A and a number field customfield_B.

I want to add customfield_A + customfield_field. Days should be added with the date.

Here is the script i use which does not work.

string format = "yyyy-MM-dd";

date resolved = customfield_A + customfield_B;

if(formatDate(resolved, format) == formatDate(currentDate()+"2d", format))
{
autotransition("status",key,true);
}

The highlighted line is causing the issue.

Below is the error i get,

"Exception while executing SIL program >>Autotransition.sil<<: [SIL Error on line: 3, column: 37] Unsupported PLUS operation between [DATE] "

Please let me know how can i achieve this through SIL script.

Thanks,

Krithica

2 answers

0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 14, 2018

I was able to do it like this

string format = "yyyy-MM-dd"

interval interv = #{number field Name} * 24*60*60*1000; // number to days
date resolv = #{date field Name} + interv; // add interval
date curDate = currentDate()+"2d"; // add 2 days to the current date
if(formatDate(resolv, format) == formatDate(curtDate+"2d", format))
{
autotransition("status",key,true);
}
0 votes
Danyal Iqbal
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 14, 2018

You can't add numbers to dates :)See Type casting

Suggest an answer

Log in or Sign up to answer