Get only date value from date/time field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2016 02:47 AM
I have a Date/Time field which has value like 2006-10-12 23:17:30
I want date alone from the field as i don't want the time appended there. Only 2006-10-12
How to get the value from glide script (server side) ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-13-2016 02:55 AM
Hi Karthik,
Use the split function as below :
//Splits your date time string into two parts based on space provided between bith and stores into an array.
var dateTime = current.nameOfField.split(' ');
var date = dateTime[0];
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-14-2016 01:38 AM
Thanks Harneet
I used .getDate along with the date field and worked!
Thanks, my second option was to use split only.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-05-2023 05:42 AM
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2018 01:16 AM
Hi Karthik,
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.
Regards
Santosh Kshirsagar