- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2025 02:56 PM
I am trying to know how do i change the date format from yyyy-mm-dd format to dd-mm-yyyy format using validation regex?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2025 06:02 AM
I am trying to change the date format on a task I am working on. Will the code only apply to the task i am trying to complete or will it affect evrything on the system?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2025 05:11 PM
Can you provide a little bit more context, a description of the actual problem you are trying to solve?
Where and for what purpose do you want to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-22-2025 07:25 PM
what's your actual business requirement?
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
‎01-22-2025 07:27 PM - edited ‎01-22-2025 07:28 PM
Hi @Lanre Ololade ,
I dont think we can change dateformat via regex, as regex is checking the input value based on given pattern but not changing the input.
You can change the dateFormat using the getByFormat() method. Check the below code.
var gd = new GlideDate();
gs.info("Default "+gd);
var formattedDate = gd.getByFormat('dd-MM-yyyy');
gs.info("dd-MMYYYY " +formattedDate);
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-23-2025 06:02 AM
I am trying to change the date format on a task I am working on. Will the code only apply to the task i am trying to complete or will it affect evrything on the system?