Need to create a report with specific dates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Saturday
Hello Community, I need your help with the following requirement:
I am creating a report for a specific table but in this report i need to show only those records which were created from 21st of last months to 20th of the current month. This report will be scheduled on 1st of each month and the client wants only records which were created on 21st of previous month to 20th of current month to be populated in the report.
So for example, a report will be sent to 1st Feb to the client then in that report they would want records which were created on 21st Dec to 20th Jan.
Can anyone help how I can achieve this with the conditions or script needed for a report? Thanks in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Saturday
Hi @YashSha9462
You don’t need any script for this. You can achieve it directly using relative date conditions in the report.
While creating the report, add the following conditions on the Created field:
Created on or after → Last month → 21
Created on or before → This month → 20
Then schedule the report to run on the 1st of every month.
ServiceNow will automatically calculate the correct date range each time the report runs.
For example, when the report runs on 1st Feb, it will pick records created between 21st Dec and 20th Jan, which matches your requirement.
This approach is dynamic, works every month, and doesn’t require any scripting.
If you found this useful, feel free to mark it as Accept as Solution and Helpful. It makes my day (and helps others too 😉).
Regards,
- Ankit
LinkedIn: https://www.linkedin.com/in/sharmaankith/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sunday
Hello @Ankith Sharma ,
Thank you for providing a solution. But while trying your solution i found an issue with selecting the date in the respective filter.
When I select Created on or after → Last month. But I am not able to select any date as you suggested in your solution. Can you please let me know how can I select a date in this filter as you have suggested.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Saturday
HI @YashSha9462 ,
1. Create a New report (sys_report table) and follow the bewlow filter condition
2. you can schedule report here in scheduled Job
Regrards,
Rajesh Gillerla.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sunday
Hi @Rajesh Gillerla ,
Thanks for your response. I have a doubt regarding this solution though, If we select the hardcoded date in the filter then how will it fetch the results for the upcoming months. For eg: In March, i would want the records created between 21st Jan to 20th Feb.
Thanks
