GarethJ1

Problem using addDays with UK date format

Discussion created by GarethJ1 on May 1, 2018
Latest reply on May 2, 2018 by GarethJ1

Hi everyone, I'm trying to get a date field (Due Date) to be automatically calculated by adding 2 days to another date field (Date Received) using the code below:

 

if (typeof [[Date_x0020_Received]] !== 'string') {
return [[Date_x0020_Received]].addDays(2);
}
return null;

 

However, this is calculating the incorrect date as shown below:

It seems to be adding to the month value rather than to the days.  I assume this is something to do with the locale as the code seems to be operating using US format where we are using UK format for dates.  I've tried adding .localeFormat("dd/MM/yyyy") to the above code but this makes no difference.

 

I'd be grateful if someone could let me know if there's anything I'm doing wrong or a way around this?

Outcomes