- My View
I want the difference of two date fields (to_date - from_date) in scoped application. I tried using dateDiff() method, but it was showing error that dateDiff is not allowed in scoped applications.
Could any one of you please help me in this regard.
Thanks in advance.
Maybe the use of the class "GlideDateTime" and the function "subtract" is what you're after.
Alternatively the use of "GlideDuration" may also be of use, as discussed by Cory.
Can you try the following for me and let me know if it works.
var t = new GlideDateTime(current.to_date); var f = new GlideDateTime(current.from_date); var dur = GlideDateTime.subtract(t, f); gs.info(dur.getDisplayValue());
It was not displaying any value and when I modified the last line as
It was showing error.
The function Subtract() expects two parameters of class "GlideDateTime", in your example you were parsing in "GlideElementGlideObject" (ie. current.to_date), hence why you are seeing the error.
You need to parse the glide value into and create a GlideDateTime object. Please note my line 1 and 2 is different to your code.
GowriSankar, Community Citizen :)
Award Correct Answer if my Solution Works, Mark helpful if it helps...