- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi @chandan86patra ,
Flow Designer has no built-in action for days between two dates, so use an inline script in Set Flow Variables:
- Create an Integer flow variable (e.g. days_since_dob).
- In Set Flow Variables, select it, click the script icon (</>) on the value field, and paste:
var dob = new GlideDate();
dob.setValue(fd_data.flow_var.date_of_birth.toString());
var today = new GlideDate();
return Math.round((today.getNumericValue() - dob.getNumericValue()) / 86400000);Using GlideDate for both dates avoids the time and time-zone offsets that usually break GlideDateTime calculations.
If it fails, make sure date_of_birth is populated by an earlier step, and check the error in the execution details.
Mark this as Helpful if it clarifies the issue.
Accept the solution if this answers your question.
Regards,
Vaishnavi
Technical Consultant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hello @chandan86patra ,
In your script GlideDateTime expects the format yyyy-MM-dd HH:mm:ss, but fd_data.flow_var.date_of_birth.toString() often includes unexpected formatting or spaces depending on the variable type.
try this script :
var inputDate = fd_data.flow_var.date_of_birth.toString();
// Initialize GlideDateTime objects for both dates
var startDate = new GlideDateTime(inputDate + " 00:00:00");
var todayDate = new GlideDateTime(); // This automatically fetches current date and time
// Subtract the start date from today's date to get a GlideDuration object
var duration = GlideDateTime.subtract(startDate, todayDate);
// Extract the total number of days from the duration object
var days = duration.getDayPart();
return days;
Also Refer this :
Calculate number days between two dates in flow designer
If my response helped mark as helpful and accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi @chandan86patra ,
Flow Designer has no built-in action for days between two dates, so use an inline script in Set Flow Variables:
- Create an Integer flow variable (e.g. days_since_dob).
- In Set Flow Variables, select it, click the script icon (</>) on the value field, and paste:
var dob = new GlideDate();
dob.setValue(fd_data.flow_var.date_of_birth.toString());
var today = new GlideDate();
return Math.round((today.getNumericValue() - dob.getNumericValue()) / 86400000);Using GlideDate for both dates avoids the time and time-zone offsets that usually break GlideDateTime calculations.
If it fails, make sure date_of_birth is populated by an earlier step, and check the error in the execution details.
Mark this as Helpful if it clarifies the issue.
Accept the solution if this answers your question.
Regards,
Vaishnavi
Technical Consultant
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
what's your exact business requirement here?
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
