Get dates and compare them in same format

Tapish Sharma1
Kilo Sage

Hi All, 

I am trying to compare the start_date_time and repeat_until of schedule and find out if repeat_until is after the start_date_time. 

But I am getting repeat_until value in a different format than start_date_time and its giving wrong value while comparing them.  for eg if start date is - 10/01/2023 09:00:00  and repeat until is 18/01/2023  when I get there values as - Start date value - 

2023-10-01 09:00:00

repeat_until value -

2023-01-18 00:00:00

 As a result the compareTo is not working 

Below is my code - 


var start_time = new GlideDateTime(sch.getDisplayValue('start_date_time'));

var end_time = new GlideDateTime(sch.getDisplayValue('end_date_time'));

var repeat_until = new GlideDateTime(sch.getDisplayValue('repeat_until'));

gs.info(start_time)

gs.info(repeat_until)


gs.info(repeat_until.compareTo(start_time))

 

TapishSharma1_0-1673427824323.png

 

0 REPLIES 0