How to compare previous value and current value of date field?

abhi710
Tera Contributor

Hi All,

I have a requirement stating that, In my form there is date/time field. I need to write a client script on that field. Whenever i select the date before last 6 months of previous value it should throw me an error/warning like "Date cannot be before last 6 months" & for future date it should throw me an error like "Date cannot be in future". I need to validate from value in date field. For example date field has 2/4/2020, this field can update only up to past 6 months(i.e. till oct/2019) and do not update to future date.

 

How can we achieve this by using client scripts?

Thank you all in advance.

7 REPLIES 7

Hello @abhi710 ,

Please use condition like below: Screenshot 2023-05-12 at 6.42.55 PM.png

If my answer solved your issue, please mark my answer as āœ…Correct & ļ‘Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

Priyanka0402
Mega Sage
Mega Sage

Hello @abhi710 ,

 

Did you try the above solution?

If my response helped please mark it correct and close the thread.

 

Thanks.

Hi @Priyanka0402 ,

Yeah, tried but not working as the field is date/time.

Regards

Abhi