Convert a GlideDate into a GlideDateTime

rasandro1407
Tera Contributor

Hey Everybody,

 

I want to compare two Dates with the after() and before() methods from the GlideDateTime type. But my dates have the type GlideDate.

 

Can I covert a GlideDate into a GlideDateTime date?

 

Thanks already!

rasnadro

2 ACCEPTED SOLUTIONS

Aman Kumar S
Kilo Patron

Yes, you can:

var gd = new GlideDate();// your glidedate field
gs.info(gd);
var gdt = new GlideDateTime(gd.getValue());// your glidedatetime value ---- line 3
gs.info(gdt);

 

Lets say if it a form field, you can just place the field value in line 3

View solution in original post

Hi @rasandro1407 ,

Good to know, my response helped you.

If your issue is resolved, please mark the response as correct and close the thread.

 

 

View solution in original post

3 REPLIES 3

Aman Kumar S
Kilo Patron

Yes, you can:

var gd = new GlideDate();// your glidedate field
gs.info(gd);
var gdt = new GlideDateTime(gd.getValue());// your glidedatetime value ---- line 3
gs.info(gdt);

 

Lets say if it a form field, you can just place the field value in line 3

Hi @rasandro1407 ,

Good to know, my response helped you.

If your issue is resolved, please mark the response as correct and close the thread.

 

 

Gunjan Kiratkar
Kilo Patron

Hi @rasandro1407 ,

You can use below methods for that :-

var gDate = new GlideDate();
var formattedDate = (gDate.getByFormat('yyyy-MM-dd HH:mm:ss'));
gs.print(formattedDate);