- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2025 09:02 PM
In a catalog item, I have a date field where the format appears as dd/mm/yyyy for me, which is causing my script to not execute properly. However, when I impersonate another user, the date format changes to yyyy/mm/dd, and the script executes fine.
I checked System Properties, where the date format is set to yyyy/mm/dd, but for my account, it still shows dd/mm/yyyy. I’m not sure if I made any changes earlier.
Can someone help me understand why this is happening and how to fix it so that my date format also appears as yyyy/mm/dd?
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2025 09:18 PM
Hi @Rishabh_N ,
Please check the user preference in your account:
Under Language and Region:
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2025 09:31 PM
Hi @Rishabh_N ,
You can use below script to format date field:
var date = new GlideDate();// replace new GlideDate() with the incoming date
var dateNew = date.getByFormat('yyyy/MM/dd'); // now use the dateNew to set the field value
Regards,
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2025 09:54 PM
no scripting required. you can simply use UI policy and you need not worry about the date format
No Code date validations through (Catalog) UI Policies
use this in UI policy condition
Your Date relative before 7 days from now
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2025 09:18 PM
Hi @Rishabh_N ,
Please check the user preference in your account:
Under Language and Region:
Mark this as Helpful / Accept the Solution if this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2025 09:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2025 09:25 PM
it depends on logged in user's date format.
what validation are you planning to run? you can tweak it to ensure it works in all formats.
share the business requirement and what's currently configured
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2025 09:49 PM
The scenario is that the selected date should be at least 7 days from the current date. I have written a Script Include and a Client Script for this. However, even when I select a date within the allowed range, it still throws an error when the date format is dd/mm/yyyy. But when I impersonate another user, it works fine when the format is yyyy/mm/dd. this might be because dateDiff is only working correctly with the yyyy/mm/dd format.