Glide record query on dates only and not time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2017 10:22 AM
I want to write a glide record query that looks at the created date only and not the time. Is it possible to parse out the time? The field type I'm using is a Date/Time field.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2017 10:49 AM
Here is the sample script that queries the incident table and returns the numbers that are created today.
var gdt = new GlideDateTime();
var dte = gdt.getDate(); //gets date
var gr = new GlideRecord('incident');
gr.addQuery('sys_created_on','STARTSWITH',dte);
gr.query();
while(gr.next()){
gs.log(gr.number);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2017 10:53 AM
That is when encoded queries come into picture. What is your exact use case
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-01-2020 11:00 AM
Hello,
You can also try below script which is working for me while querying table
var dte = gdt.getDate().getByFormat('YYYY-MM-d');;
gr.addEncodedQuery("^sys_created_on>javascript:gs.dateGenerate('"+dte +"','00:00:00')^sys_created_on<javascript:gs.dateGenerate('"+dte +"','23:59:59')");
Regards
Sumedh Kharode
www.dxsherpa.com