Why below script/ query is not working after passing 2 dates in addEncodedQuery ?

Virendra K
Kilo Sage

Hi All,

 

I am trying to pass 2 dates in addEncodedQuery but its not working. There is some mistake while passing the dates parameter but not clear on this. Please suggest.

 
             var output=[];
             var gr1 = new GlideRecord('cmn_schedule_span');
             var query2= "schedule.type=blackout^schedule.name=Central Winter Break^u_start_time>=javascript&colon;gs.dateGenerate('2024-09-16','09:08:46 AM')^u_end_time<=javascript&colon;gs.dateGenerate('2024-09-17','09:08:46 AM')";
            gr1.addEncodedQuery(query2);
            gs.print('VIREN : Q2 = ' + query2);
            gr1.query();
            while (gr1.next()) {
                gs.print("VIREN Passed");
                output.push(gr1.name+ ' -- '+ gr1.start_date_time + ' to ' + gr1.end_date_time);
                }
           gs.print('VIREN TESTING Result Before Output is ' + output);

 

6 REPLIES 6

SumanKumarM
Tera Contributor

Hi Virendra K,

Below code worked for me.

var output = [];
var gr1 = new GlideRecord('cmn_schedule_span');
var query2 = "schedule.type=blackout^name=Weekends^start_date_time=20110105T010000^end_date_time=20110105T050000";
gr1.addEncodedQuery(query2);
gs.print('VIREN : Q2 = ' + query2);
gr1.query();
while (gr1.next()) {
    gs.print("VIREN Passed");
    output.push(gr1.name + ' -- ' + gr1.start_date_time + ' to ' + gr1.end_date_time);
}
gs.print('VIREN TESTING Result Before Output is ' + output);

SumanKumarM_0-1726518688915.png

 

Please mark helpful, if it works for you.

 

Thanks,

Suman.

Thanks for the reply @SumanKumarM

  Challenge is, I want to check the dates in between start_date_time and end_date_time. 

  suppose,

start date =2024-09-17 06:22:00

End date = 2024-09-19 06:20:35

so I will pass the above date range and try to check the dates which is within the range. for ex: 2024-09-18

I am trying to pass like "start_date_time>=20110105T010000^end_date_time<=20110105T050000"  but no luck.