AnsweredAssumed Answered

finding  the difference between the 2 Dates

Question asked by amitash.pattnaik983074 on Oct 7, 2017
Latest reply on Oct 8, 2017 by leif.jacobsen@dagrofa.dk

I want to first convert the input value from character to Date and find out the difference between the input and Current Date. The input value is coming from a Flat file. i  use JavaScript.My scripting is like this:-

var inp =Time;
function parseDate(input) {
var parts = input.match(/(\d+)/g);
// new Date(year, month [, date [, hours[, minutes[, seconds[, ms]]]]])
return new Date(parts[0], parts[1]-1, parts[2]); // months are 0-based
}

var res = parseDate(inp);
var date1=res;
var date2 = new Date();

var timeDiff = Math.abs(date2.getTime()- date1.getTime());
var diffDays = Math.ceil(timeDiff / (1000 * 3600 * 24));
var result = diffDays-1 ;

 

This scripting is working fine in online Java Script interpreter.

But when i use it in a map shape,it throws error .

The error message is like this:-[Function: New Map Function 2, Scripting]: Error executing custom script: TypeError: input.match is not a function in <eval> at line number 3; Caused by: TypeError: input.match is not a function in <eval> at line number 3; Caused by: TypeError: input.match is not a function.

 

 

Guys Could you please help on this?

Outcomes