- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2023 05:52 AM - edited ‎05-24-2023 05:55 AM
Hi,
When I'm writing an business rule to apply my logic to the table, I encountered a problem is that I don't know what is the default date format at server side in ServiceNow. Furthermore, why is an GlideDateTime or GlideDate object takes the user date format when I call object.getDisplayValue() but it doesn't take user's date format when it stands alone like in the code example:
// User format: dd/MM/yyyy
var date1 = new GlideDate();
print(date1); // Auto format to yyyy-MM-dd
var date2 = new GlideDate();
print(date2.getDisplayValue()); // Format the date value to user's date format set in profile
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2023 06:15 AM
Hi @sieusaopolo15 ,
The default date format is the System date format that is set in your instance
When you don't use getDisplayVaule, you will get your system date format
But if you use getDisplayVaule, you will get date format s uset in user's profile
This is OOB behaviour or how ServiceNow built the functions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2023 06:15 AM
Hi @sieusaopolo15 ,
The default date format is the System date format that is set in your instance
When you don't use getDisplayVaule, you will get your system date format
But if you use getDisplayVaule, you will get date format s uset in user's profile
This is OOB behaviour or how ServiceNow built the functions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2023 06:22 AM
Hi @Manmohan K,
Thanks for helping me understand how our ServiceNow's system works.
Really helpful thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2023 06:24 AM
Hi @sieusaopolo15 ,
ServiceNow default date format is yyyy-MM-dd. when serviceNow display the date in form/list UI, it gets displayed based on date format selected by user in the user profile. The same format will be returned by getDisplayvalue() as well.
few lines from servicenNow documentation.
The glide.sys.date_format property defines the date format. An administrator can modify the property by navigating to System Properties > System. The default format is: yyyy-MM-dd.
Hope this is helpful to you.