Creating Function field using glidefunction:datediff()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 06:18 PM
I want to have a column in the list giving how many days back the incident was created without storing it in the database. Therefore, I do not want to create a database column and maintain it all the time. Therefore, I created a Function field on my table.
By doing: using dictionary-> New -> a record with Function Field = Yes
with Function definition as glidefunction:datediff(sys_created_on,now());
Instead of number of days, it is computing 1969-12-31 23-28-34. I guess that there is a mismatch in the format of sys_created and now(). Can someone please suggest what function do I use instead of now().
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 07:53 PM
Hi Rakesh,
So you have created a field of type Function?
Can you share screenshot?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 09:41 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-23-2020 10:29 PM
Hi,
so for that string field you need to store default value as difference between now and created time?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-24-2020 04:00 PM
Thanks folks, I figured out:
1) The Type should have been equal to Duration instead of String.
2) The now() attribute should be first as it is Now minus sys_created_on.
glidefunction:datediff(now(),sys_created_on);
Thanks for your help.