how to check date difference in flow designer script action ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 12:44 AM
here is the code for workflow "waiting for condition" -
answer = gs.dateDiff(gs.nowDateTime(), current.variables.u_deactivation_date, true);
bhut if i try the same code in flow designer script action as below -
var now = new GlideDateTime();
var glideTo = inputs.u_deactivation_date;
var dur = GlideDateTime.subtract(now, glideTo).getDisplayValue(); //line 3
var hour = dur.getByFormat('HH');
outputs.datdiff = hour;
but here for line 3 code i am getting error , can anyoe please help how to calculate that in flowdesigner ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-05-2022 02:05 AM
Hi,
Could you please explain what you are trying to achieve with this script?
I'm asking because there might be an alternative as you are referring to "wait for condition".
Tudor

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2022 03:46 AM
Hi,
I wrote a Flow designer tool for date comparison that is free to use a while ago. Use if you like.
Regarding your script, the GlideDateTime.subtract() method requires that you pass it 2 GlideDateTime objects, and currently the second one is probably evaluated as a String, which will generate an error.
To correct, write something like this:
var now = new GlideDateTime();
var glideTo = new GlideDateTime(inputs.u_deactivation_date.toString());
var dur = GlideDateTime.subtract(now, glideTo).getDisplayValue();