---
original_url: "https://jace.pro/blog/no-code-date-validations/"
format: markdown
ai_optimized: true
---

No Code Date Validations- # No Code Date Validations

September 7, 2019 [servicenow ](/tags/servicenow/)[ui-policies](/tags/ui-policies/)

  Enable AI AnimationI’ve in the past had to write some… cludgey date comparisons. I’m not proud of them. I’m just glad I didn’t have to look at them later.

Had I thought about what Mark Ragavan wrote about, it would have saved me probably days over my development time in the last 10 years.

Really, there’s some common types of checks and actions for dates.

Is it in the past?
- Is it within a window? e.g. After 7 days from now.
- Is it after another date on the form?

To show this I’ll add some reproduction steps below. Start out with my [ATF Scoped App](https://atf.jace.pro/);

- On your PDI import my [“ATF” scoped app](https://atf.jace.pro/).
- URL: `https://github.com/jacebenson/atf.git`
- Change scope to “ATF”
- Goto maintain items, and look for “Test Item”

Now that you’re here we can quickly test this out.

## [](#disallow-past-dates)[Disallow past dates](https://jace.pro/post/2019-09-06-no-code-date-validations/#disallow-past-dates)

- Create a UI Policy with the condition, `Date Before Today`.

- Add a UI Policy action for the field `Date` and check the `clear value` checkbox.

- Update the variable `Date` to have `Example text` of “Date cannot be in the past.”

Try it out.

Now that you’ve seen it, it should be pretty clear how to apply this to a number of different situations. I just wanted to share as this is a great way for me to remember.

Further Reading: [No Code dates validations thru Catalog UI Policies](https://community.servicenow.com/community?id=community_article&sys_id=f61964aadbcb3fc85129a851ca9619eb)

---
[View this page on GitHub](https://github.com/jacebenson/jace.pro/tree/main/./src/posts/2019/2019-09-06-no-code-date-validations.md).

[No Code Date Validations](https://jace.pro/blog/no-code-date-validations/) [Jace Benson](https://jace.pro) ![Jace Benson](https://jace.pro/icon-512x512.png)

---

*This content is from Jace Benson's ServiceNow and tech blog at jace.pro*
*Original post: https://jace.pro/blog/no-code-date-validations/*
