How to query date/time field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2018 05:09 AM
I have two date/time fields, callback start date and end date. End date is populated with 2 hours after the start time. When more than 5 incidents with same start date and end date are submitted, it should thrown an alert saying that there are already 5 incidents with the same start date and end date. And also it should clear the start date and end date.
I have created an on change client script (onchange of end date) and script include and I've passed the start and end date values to the script include. I'm unable to query the start and end dates in the script include. I tried querying the incident table with start date and end date. It is not querying the values, since both are date/time fields.
I have tried the same by creating two drop down fields for start and end time and one date field for callback date. It was working fine that time. But based on the requirement, I have changed it into two date/time fields. I have attached the scripts for reference.
Please help with your suggestions.
Thanks in advance,
Manimozhi
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2018 10:03 PM
Please use getDate method to get date alone and compare using startswith.
var gdt = new GlideDateTime();
gdt.setNumericValue(sec);
var checkDate = gdt.getDate(); //getting only date component
var gr = new GlideRecord('u_sps_availability');
gr.addQuery('u_date','STARTSWITH',checkDate); //Compare using startswith
gr.query();
if(gr.next()){
gs.print("yes");
}
Thanks,
Aditya Telidevara