- 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: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: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