Compare dates in different format

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2022 10:10 PM
Hi all,
We are looking for a way to compare different date formats. We store date in a string field & then we want to add a validation on server side that if the date is before 02/02/2022 then abort insertion.
But the problem is that user who submits the record in this table, he might have different date format which will cause issues in this date comparison since we have used (dd/MM/yyyy) & user may have date format as (yyyy/MM/dd). Also before hand we don't know user will have which format in his profile.
So what I'm looking for is either a way to compare 2 different date formats or maybe convert any string date format to a common format which helps in date comparison.
Thanks,
Utpal
- Labels:
-
Search
-
User Experience and Design
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2022 10:18 PM
Hi
Check the below link it may help you
https://community.servicenow.com/community?id=community_question&sys_id=80cd59041b66f810ada243f6fe4bcb4a
https://community.servicenow.com/community?id=community_question&sys_id=0aa7ff65db816744b2102926ca9619c0
Thanks
Chandu Telu
Please Mark the answer helpful/correct , if it is

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2022 12:04 AM
Thanks but it's not helpful

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2022 10:28 PM
Hey,
I think when we talk about the date formatting, its all for the display value, the backend value remains consistent
Follow below article to validate:
https://community.servicenow.com/community?id=community_question&sys_id=890cc725db9cdbc01dcaf3231f961964
Feel free to mark correct, If I answered your query.
Will be helpful for future visitors looking for similar questions 🙂
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2022 10:31 PM
Hi,
no worries in date format
You can use UI policy for this with no script
Like this
Output with Date Format yyyy-MM-dd See the date format for Opened
Output with date format - dd/MM/yyyy - See the date format for Opened
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader