Help with Scripting to Filter sys_user Table by Created Column
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2024 02:30 AM - edited 07-16-2024 02:40 AM
Hello,
I am new to scripting in ServiceNow and need assistance with
creating a dynamic filter for a report that extracts data from the sys_user table based on the Created column. I'd like to achieve the following filtering criteria:
- A specific date and time (e.g., 2024-01-01 00:00:00)
- Wednesday 2 weeks ago
- If the current day is Monday or Tuesday, the filter should input the date from 5 days ago. If it is any other day, the filter should input the date from 4 days ago at 23:59:59.
Thank you in advance for your assistance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2024 07:38 AM - edited 07-22-2024 07:41 AM
Hello @Slava Savitsky and @OlaN,
I created a script to get a specific date. Please see the screenshot below and correct me if I'm wrong.
I want to use that script to filter the Created date of Users table,
- Created ON javascript: new Date.getDate(1)
- Created BETWEEN javascript: new Date.getDate(1) and javascript: new Wed2WeeksAgo.getDate(1)
My problem now is how to use the created script to filter the table?
Thank you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2024 10:29 AM
Okay, well, sorry to disappoint, but date/time field are not available to make dynamic filter like you just described.
You can do most things and filter date/time fields with, for example, a relative time (but it's always relative to the current date, not a date selected user).