Between date query on two dates

Nikhil Gadodiya
Kilo Explorer

I have custom table where in we have 2 date and time field start and end as:

find_real_file.png

Now when user submits the new record I want to check if the entered start and end time slot is empty or not similar to that of the calendar.

How can I check that using GlideRecord Query.

9 REPLIES 9

Mark Roethof
Tera Patron
Tera Patron

Hi there,

Is this something you could simulate through the list? If so this article might help you further:
Utilizing the breadcrumb on lists to generate your query

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

I'll be using this in a business rule where we have start and end selected.

Yes I understand. Though the question is, can you already achieve such a filter through the UI? If so, you could simply copy that query and use that within script. This could reduce complexity, this could help building the query visualy, etc..

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

I tried copying that query and changing hard coded value to gliderecord object but it didn't work .

Can you please have a look at encoded query and let me know if I can change something in it

 

var b = new GlideRecord("u_multimedia");
b.addQuery("sys_id","21a214861b63041092b4fc88cc4bcbd9");
b.query();
if(b.next()){

var a = new GlideRecord("u_multimedia");
a.addEncodedQuery("u_event_start_dateBETWEENjavascript:b.u_event_start_date@javascript:b.u_event_end_date");
//a.addEncodedQuery("u_event_start_dateBETWEENjavascript:gs.dateGenerate('2020-03-17','00:00:00')@javascript:gs.dateGenerate('2020-03-18','00:00:00')");
a.query();
gs.info(a.getRowCount());
}