- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2025 05:25 AM
Hi,
I need to use a script to retrieve schedules entries with an end date later than today.
The problem is that the end_date_time field isn't in the usual date format (20251231T235900), and I can't compare it to the current date in my gliderecord. Can anyone help?
Karine
the script :
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2025 05:35 AM
Hi @Karine_M,
You can try the following code:
var today = new GlideDateTime();
today.setDisplayValue(gs.beginningOfToday().getDisplayValue());
var formattedToday = today.getDate().getByFormat('yyyyMMdd') + 'T000000';
gs.info('Formatted today: ' + formattedToday);
var nbSchedule = 0;
var gsp = new GlideRecord('cmn_schedule_span');
gsp.addQuery('end_date_time', '>', formattedToday);
gsp.groupBy('schedule');
gsp.query();
while (gsp.next()) {
gs.info('Schedule: ' + gsp.end_date_time);
nbSchedule++;
}
gs.info('nbSchedule ' + nbSchedule);
Regards,
Ehab Pilloor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2025 05:35 AM
Hi @Karine_M,
You can try the following code:
var today = new GlideDateTime();
today.setDisplayValue(gs.beginningOfToday().getDisplayValue());
var formattedToday = today.getDate().getByFormat('yyyyMMdd') + 'T000000';
gs.info('Formatted today: ' + formattedToday);
var nbSchedule = 0;
var gsp = new GlideRecord('cmn_schedule_span');
gsp.addQuery('end_date_time', '>', formattedToday);
gsp.groupBy('schedule');
gsp.query();
while (gsp.next()) {
gs.info('Schedule: ' + gsp.end_date_time);
nbSchedule++;
}
gs.info('nbSchedule ' + nbSchedule);
Regards,
Ehab Pilloor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2025 05:59 AM
Thank you very much for this quick response. It works perfectly!
Regards,
Karine