How to use today's date in a sql statement's where clause? I need to get data from a database based on today's date.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 06:49 AM
Hello All,
How to use today's date in a sql statement's where clause? I need to get data from a database based on today's date.
Thanks!!
Labels:
- Labels:
-
Integrations
-
Scripting and Coding
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 06:55 AM
var gdt = new GlideDateTime();
var mydate = gdt.getDate();
var gr = new GlideRecord('your_table');
gr.addQuery('your_field','STARTSWITH',mydate);
gr.query();
while(gr.next()){
// add your logic
}
Mark comment as correct if this answers.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2019 07:01 AM
You need to use the date format which db understands, use timestamp instead of date. We recently found a known issue on use date()
