- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2017 04:31 AM
here is the business rule I've found in the community, for a field called u_days
u_setDays();
function u_setDays() {
var dte = gs.dateDiff(current.u_date_submitted.getDisplayValue(), current.u_date_accepted.getDisplayValue(); false);
current.u_days = dte;
}
It's calculating the number of days correctly, but I need it to show days only, not ddd hh:mm:ss
How do I set the display to show days only?
Any suggestions are much appreciated!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2017 06:16 AM
Hi Cheryl,
You can return the difference between the dates to a GlideDuration object, and get the number of days from GlideDuration using getDayPart().
u_setDays();
function u_setDays() {
var dte= GlideDateTime.subtract(new GlideDateTime(current.u_date_submitted), new GlideDateTime(current.u_date_accepted));
current.u_days = dte.getDayPart();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2017 06:25 AM
Now the calculation is not working; it is giving me a '1' regardless of the dates. Also, should u_days be of type Integer?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2017 06:28 AM
What type of field is u_days currently?
It doesn't necessarily HAVE to be an integer field. It might be helpful.
If you want to do calculations against it (like differences, sums, etc.) then an integer is helpful. It also allows you to validate that you're not putting garbage data like strings "xxx" in the field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2017 06:16 AM
Hi Cheryl,
You can return the difference between the dates to a GlideDuration object, and get the number of days from GlideDuration using getDayPart().
u_setDays();
function u_setDays() {
var dte= GlideDateTime.subtract(new GlideDateTime(current.u_date_submitted), new GlideDateTime(current.u_date_accepted));
current.u_days = dte.getDayPart();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2017 06:39 AM
Jenny,
It worked! Thank you!
Thanks also to Chuck and Ankur, I am learning a lot here!