- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 01:00 AM
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
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 01:14 AM - edited 11-23-2022 01:15 AM
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
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 03:23 AM
Hi @rasandro1407 ,
Good to know, my response helped you.
If your issue is resolved, please mark the response as correct and close the thread.
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 01:14 AM - edited 11-23-2022 01:15 AM
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
Aman Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-06-2022 03:23 AM
Hi @rasandro1407 ,
Good to know, my response helped you.
If your issue is resolved, please mark the response as correct and close the thread.
Aman Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-23-2022 01:14 AM
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);