Post

2 followers Follow
0
Avatar

Date and 2 calculations with Syntax errors

I have an App in that app I'm using 3 fields to track assets and know when they have hit their 10 year or older mark.

-The First field(Date of Manufacture) is a date field using only a "start" date( no times or end date)

-The second field(DoM Years) is a calculation field, which is to calculate years the asset has been in service, the calculation I am using is 

     var d1 = moment(@Date of Manufacture);
     var d2 = moment();
     var result = d2.diff(d1, 'years');
     result;

-The third field that I'm having trouble with is an if then statement 

I need the third field to reference the second field's calculation and if the years are equal to or greater than 10 years mark it as 'yes' and if it is less than 10 years mark it as 'no' this is what my brain types it as but the syntax is wrong 

{if (@DoM Years >= '10' "yes")
else 'no'}

Jabin Young

Please sign in to leave a comment.

1 comment

0
Avatar

Hi Jabin,

it's either: 

if (@DoM Years >=  10){
"yes"
}else{
'no'
}:

or shorter: 
@DoM Years >=  10 ? "Yes" : "No"

But be careful with the calculation in DoM Years. I've described the issue with moment() = current date here: https://help.podio.com/hc/en-us/community/posts/115000113951-Trying-return-a-number-on-subtracting-today-s-date-from-a-given-date-in-a-field-?page=1#community_comment_115000105451

Rainer 

Rainer Grabowski 0 votes
Comment actions Permalink