- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2017 05:51 PM
We have a custom attribute, Committed SLA (u_eta), which is a date field type. We want to create a report that shows incidents where u_eta > closed.
Closed is a date/time field, so it does not appear as an option to compare to the date (only) field, u_eta.
Is there a way to compare the dates (only) of these two fields? Ideally, we could just strip-out the time component of the closed date/time value.
Solved! Go to Solution.
- Labels:
-
Reporting
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2017 11:25 AM
To my knowledge, the best way to do this would be to create another field that doesn't show up on the form called something like u_eta_timestamp, that's a calculated field based on u_eta. In the calculated value, set it to midnight either UTC or local time depending on your needs.
Alternatively, you could set up a u_eta_timestamp field and create a business rule to update it whenever the value of u_eta is changed.
Once you have that field defined, you can use the field comparison operators to create your queries. In this case, you'd use something like u_eta_timestamp "is more than" closed to form the comparison.
EDIT: I just worked this up in my personal instance.
I created a new ETA [u_eta] field on the incident table that is of type Date.
Your table might be different, but this should have me in a state that represents what you have now.
Next I created a Date/Time field on the Incident table called Committed SLA Timestamp [u_eta_ts]. On the Dictionary Entry page, I clicked the link to see the Advanced view of the form. After that, I clicked the Calculated Value tab and used the following script for the Calculation:
new GlideDateTime(gs.dateGenerate(current.u_eta, 'u_eta_ts'));
Here's a screenshot of the relevant part of the Dictionary Entry page:
I moved the field on the form so that it's just below the Committed SLA field so you can see its value in the screenshot below. Note that calculated value fields are read-only. In your case, you'll probably want to just remove the timestamp field from the form completely so that the user doesn't even know it's there.
Also note that the timestamp is the start of the Committed SLA [u_eta] date in local time, which in the screenshot above is PDT (UTC -7). If you want it to be UTC instead, just use the following calculation formula instead:
new GlideDateTime(current.u_eta);
In either case, you can now get the records you're looking for by querying for Committed SLA Timestamp is more than 0 Days after Closed, as shown in the following:
Hope this helps,
--Dennis R

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2017 08:27 PM
Hi John,
I believe the only way attributes can be compared if they are a part of the same table. Otherwise, they may have their tables logically joined for the attributes to compare in a report.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2017 11:25 AM
To my knowledge, the best way to do this would be to create another field that doesn't show up on the form called something like u_eta_timestamp, that's a calculated field based on u_eta. In the calculated value, set it to midnight either UTC or local time depending on your needs.
Alternatively, you could set up a u_eta_timestamp field and create a business rule to update it whenever the value of u_eta is changed.
Once you have that field defined, you can use the field comparison operators to create your queries. In this case, you'd use something like u_eta_timestamp "is more than" closed to form the comparison.
EDIT: I just worked this up in my personal instance.
I created a new ETA [u_eta] field on the incident table that is of type Date.
Your table might be different, but this should have me in a state that represents what you have now.
Next I created a Date/Time field on the Incident table called Committed SLA Timestamp [u_eta_ts]. On the Dictionary Entry page, I clicked the link to see the Advanced view of the form. After that, I clicked the Calculated Value tab and used the following script for the Calculation:
new GlideDateTime(gs.dateGenerate(current.u_eta, 'u_eta_ts'));
Here's a screenshot of the relevant part of the Dictionary Entry page:
I moved the field on the form so that it's just below the Committed SLA field so you can see its value in the screenshot below. Note that calculated value fields are read-only. In your case, you'll probably want to just remove the timestamp field from the form completely so that the user doesn't even know it's there.
Also note that the timestamp is the start of the Committed SLA [u_eta] date in local time, which in the screenshot above is PDT (UTC -7). If you want it to be UTC instead, just use the following calculation formula instead:
new GlideDateTime(current.u_eta);
In either case, you can now get the records you're looking for by querying for Committed SLA Timestamp is more than 0 Days after Closed, as shown in the following:
Hope this helps,
--Dennis R
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2017 02:31 AM
The platform does support it, condition builder soes not
A query like beneath does work,only doesnt show well in the condition builder:
last_loginMORETHANsys_updated_on@day@before@0
I would go with Dennis solution, or change the field all together to datetime, to prevent a redundant field.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2017 09:08 AM
Thanks Dennis/everyone.
I have one follow-up question. I'll create a script to copy the u_eta (date) to a new field which I'll create u_ceta (date/time). However, I was thinking...I like to use existing fields whenever possible. Before I re-purpose the ootb/built-in attribute, due_date, how can I easily determine if it is 'safe' to use due_date for this purpose.
The intended purpose of Committed SLA, btw, is to allow the Assign_to person to commit to a delivery date to the customer. This way the customer know's the Assign_to has seen the ticket and intends to deliver by the Committed SLA date (and now date & time). I know the ootb/built-in attribute, sla_due, is populated via scheduled task to calculate based on SLA values (e.g. urgency/impact/priority). And this behavior is fine.
Ideally, the Assign_to would usually/mostly commit to an SLA equal-to or before the calculated SLA (sla_due).
If I use the ootb/built-in field, due_date, for an Assigned_to to set a committed SLA date, will that screw-up any ootb/built-in workflows or be overwritten by some other ootb/built-in script?
(btw, in general, I've had a hard time understanding the ServiceNow's intended purpose is for the ootb/built-in fields. Many seem self-evident, but some you seem to have to guess. And, many don't have any descriptions or comments to explain what they are for, and often they are not covered in the Wiki or other SNOW documentation. If anyone has a master decoder-ring for all the ootb/built-in field intended purposes, that would be a huge help...probably for lots of folks.)