Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Can I compare only datepart of datetime field in query?

chanken
Tera Contributor

Hi Everyone,

Can I compare only datepart of datetime field in query?

We have a scheduled solution date field in incident management.

We want to send a notification e-mail to the owner of the incident scheduled to be resolved at next day in schedule job .

It is coded in the script as follows.

-----------------------

var todaysDate = gs.nowDateTime.split(' ')[0];

var gr = new GlideRecord('u_sys_itsm_incident');

gr.addQuery('active', true);

gr.query();

while (gr.next()) {

    var completedDate = gr.getDisplayValue('u_response_completed_at_scheduled').split(' ')[0];

    if (completedDate == todaysDate(-1)

-----------------------

Can I specify this as a query condition?

thanks.

1 ACCEPTED SOLUTION

srinivasthelu
Tera Guru

Hi Kenji,



how about a encoded query?



sys_created_onONToday@javascript:gs.daysAgoStart(0)@javascript:gs.daysAgoEnd(0),



You could apply filter like that through list view and copy them as encoded queries to your code directly..   Not readable sometimes// but  


View solution in original post

1 REPLY 1

srinivasthelu
Tera Guru

Hi Kenji,



how about a encoded query?



sys_created_onONToday@javascript:gs.daysAgoStart(0)@javascript:gs.daysAgoEnd(0),



You could apply filter like that through list view and copy them as encoded queries to your code directly..   Not readable sometimes// but