Date Type Variable Format - 3 Months Validation

dharanikumar
Giga Guru

Hi All,

We have two variables on the catalog form Start Date & End Date

Difference between the variables can not be greater than 3 months.

For Example: If Start Date is 17-Jan-2024 then the End Date (I.e.., 16-Apr-2024) should be less than 3 months
If the user enters after 16-Apr-2024 it should throw an error.

ISSUE: Date type variable returns the below value 

dharanikumar_0-1705435750207.png

 

Logs: 

dharanikumar_2-1705435891088.png

 

How can we achieve this using this format.


Thank you!!

 

1 ACCEPTED SOLUTION

So have you looked into no code date validation at all? The article also contains an example of what you are after, only thing is the example is on hours, which you can just choose a different operator for.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

View solution in original post

16 REPLIES 16

Hi Mark,

Thanks for the reply!!

My requirement is Start Date and End Date cannot be greater than 3 months.

Example: If Start Date is 17-Jan-2024 then End Date should be less than 16-Apr-2024.

Thank you!!

So have you looked into no code date validation at all? The article also contains an example of what you are after, only thing is the example is on hours, which you can just choose a different operator for.

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi @dharanikumar 

 

https://www.servicenow.com/community/itsm-forum/setting-end-date-field-to-30-days-based-on-start-dat...

 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

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/atul_grover_lng [ Connect for 1-1 Session]

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

Hi Atul,

 

There's no reason to script such. What's the reason for sharing a scripted solution and making things unnecessarily complicated and unmanageable?

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi @Mark Roethof 

 

There are many ways to do a work , I agree scripting is not best always where work can be done without code. Giving option is not a bad choice. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

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/atul_grover_lng [ Connect for 1-1 Session]

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