We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Date Filter between Months

paulmagaling
Tera Contributor

Is there any way to filter a list between months without the year?
e.g. April to September, October to March

paulmagaling_0-1769434713084.png

 

5 REPLIES 5

Dr Atul G- LNG
Tera Patron

Hi @paulmagaling 

 

OOTB it is not possible. 

*************************************************************************************************************
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/dratulgrover [ Connect for 1-1 Session]

****************************************************************************************************************

It seems impossible but, I found a way to overcome this requirement.

To get all records between specific month, I used the "trend" operator.

paulmagaling_0-1769441772980.png

 

Its_Azar
Kilo Sage

Hi there @paulmagaling 

not with the out-of-the-box Date filter alone- not possible.
But yes, it is can be done with either relative date logic or a scripted/encoded query approach,  whats the usecase?

 

You can use a before query BR if you need it to be reusable 

(function executeRule(current, previous) {
  var m = new GlideDateTime().getMonthUTC() + 1;

  if (!(m >= 4 && m <= 9)) {
    current.addQuery('sys_id', 'ISEMPTY');
  }
})();

 

☑️ If this helped, please mark it as Helpful or Accept Solution so others can find the answer too.

Kind Regards,
Azar
Serivenow Rising Star
Developer @ KPMG.

For the platform analytics dashboard, I need to filter the asset_task table using the contract.ends, and get the records from this year's October to next year's March.