GlideSystem Date Functions On Dev Instance

chriscorbett
Giga Contributor

All --

I'm wondering if there is a limitation on the GlideSystem date function on dev instances? I am incorporating query strings into a few jelly scripts on a dev instance. Queries I pulled for today work, as does a query for yesterday.

But if I put in a query that specified a start and end date, that does not work no matter what I try.

So, for example, this query to pull records for today is working:

var dateString = "entry_dateONToday@javascript:gs.daysAgoStart(0)@javascript:gs.daysAgoEnd(0)";

  var target = new GlideRecord('tablename');

  target.addEncodedQuery(dateString);

  target.query();

But this attempt where I try to pull records from this past Sunday until today is NOT working:

  var dateString = "entry_dateBETWEENjavascript:gs.dateGenerate('2016-03-06','start')@javascript:gs.dateGenerate('2016-03-08','end')";

  var target = new GlideRecord('x_27491_hi_tracker_daily_stats');

  target.addEncodedQuery(dateString);

  target.query();

It seems that any time I try to specify a specific date in some way the query does not work.

Is there a reason for this and if so how do I correct it?   Basically, I'm trying to retrieve results from the Sunday of that given week to the current time.

If anyone can show me a better way of doing this or explain what I might be doing wrong in my query, I would appreciate it!

Thanks,

Chris

8 REPLIES 8

manikorada
ServiceNow Employee
ServiceNow Employee

Chris,



Try to do something like:



var dateString = "entry_dateBETWEENjavascript:gs.dateGenerate('2016-03-06','00:00:01')@javascript:gs.dateGenerate('2016-03-08','23:59:59')";


Thanks Mani. I did try it that way as well and that did not work either...


chriscorbett
Giga Contributor

Anyone have any other thoughts?


I have something in my head from my scriping course that some methods etc. doesnt work inside a own application by default and looking to your query it seems to be in your own applicationen. Just for fun, try do the same query on for example the incident table.



//göran