Thursday 14 July 2016

Calculating Difference Between two dates in Siebel eScript

Hello All,

Very often we get to work with dates in Siebel, comparing two dates, Subtracting two dates. So how do actually date types field behave. In eScript we declares variable as var which is general format as eScript is not strongly typed language.
I had a very simple requirement to compare Today's date with created date calculate age of record.
Logic is very simple,

Today()-RecordDate, and it should give me the output but it didn't work. :(

Here comes the use of Date() object to actually compare, manipulate date variable.

so the expression is modified to ,

var Today = new Date();
var RecordDate = new Date(Rec_Date);

Difference = Today - RecordDate ;

Now it works as expected, the difference is in Milliseconds, that can be converted to Years or Days by dividing with factor.

To Days, Difference/(1000*60*60*24);
To Years, Difference/(1000*60*60*24*365);

Hope this was helpful.

No comments:

Post a Comment

Siebel GoTo View - Handling Realtime cases

 Hello All,  We all must have used GoTo view functionality of siebel to navigate to a particular view from current view. What if the require...