Get only date value from date/time field

Not applicable

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) ?

5 REPLIES 5

Harneet Sital
Mega Sage

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];


Not applicable

Thanks Harneet



I used .getDate along with the date field and worked!


Thanks, my second option was to use split only.


Thank you

SantoshK1857223
Mega Sage

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

find_real_file.png

www.dxsherpa.com