- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2022 03:52 AM
Hi,
How can I extract the date from a Date/Time field?
In a table we have created field which have record creation date and time. Now I created another field Case Created Date of type Date and I need to extract only the date from created field and store that in Case Created Date field.
I tried one approach by using calculated value related list. But its not working for some corner cases.
What might be the wrong here? Is there any other approach I can do?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2022 03:59 AM
Hello,
Please use the below:-
var gdt = new GlideDateTime(current.sys_created_on);
var date = gdt.getLocalDate();
Please mark answer correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2022 03:58 AM
Hello,
use this syntax to get only date from DateTime field:-
var gdt = new GlideDateTime("2011-08-31 08:00:00");
gs.info(gdt.getDate());
Please mark my answer as correct if it helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2022 03:59 AM
Hello,
Please use the below:-
var gdt = new GlideDateTime(current.sys_created_on);
var date = gdt.getLocalDate();
Please mark answer correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2022 03:59 AM
Hi,
Should be simple as this
var str = g_form.getValue('sys_created_on');
alert(str);
str = str.split(' ');
alert(str[0]); //this gives date
alert(str[1]); //this gives time