
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2016 05:20 AM
I need to get a date range between 6:30am yesterday and 6:30am today.
I know I can do this:
closed_atBETWEENjavascript:gs.dateGenerate('2016-11-01','06:30:00')@javascript:gs.dateGenerate('2016-11-02','06:30:00')
But as you see I'm hard-coding the day/month/year.
I'm curious, will this work?
closed_atBETWEENjavascript:gs.dateGenerate(gs.daysAgoStart(0),'06:30:00')@javascript:gs.dateGenerate(gs.daysAgoEnd(0),'06:30:00')
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2016 06:04 AM
Something like this may work:
closed_atBETWEENjavascript:gs.dateGenerate(gs.beginningOfYesterday().slice(0,10),'06:30:00')@javascript:gs.dateGenerate(gs.beginningOfToday().slice(0,10),'06:30:00')
Please feel free to connect, follow, mark helpful / answer, like, endorse.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2016 06:04 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2016 07:04 AM
Something like this works too...
var das = gs.daysAgoStart(0);
das = das.split(" ");
var dae = gs.daysAgoEnd(0);
dae = dae.split(" ");
gr.addEncodedQuery("closed_atBETWEENjavascript:gs.dateGenerate('" + das[0] + "', '06:30:00')@javascript:gs.dateGenerate('" + dae[0] + "', '06:30:00')");
But I'll try yours because it's prettier
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2016 07:15 AM
And I like keeping encoded queries on a single line, even with javascript embedded (that way, you can use it in GQL).
BTW, if you want to use daysAgoStart(), I believe "yesterday" should be
gs.daysAgoStart(1)
Also to add to this, since some functions take the input in local time and output in GMT, I'd suggest testing some edge cases to make sure it's working as intended.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2016 07:36 AM
Well... just ran into something very confusing.... these gs.dateGenerate()'s are failing!
Here's the code that generates the gs.log()'s:
var das = gs.daysAgoStart(0);
das = das.split(" ");
gs.log("-}> gs.daysAgoStart(0): " + gs.daysAgoStart(0));
gs.log("-}> das[0]: " + das[0]);
var dae = gs.daysAgoEnd(0);
dae = dae.split(" ");
gs.log("-}> gs.daysAgoEnd(0): " + gs.daysAgoEnd(0));
gs.log("-}> dae[0]: " + dae[0]);
var bot = gs.beginningOfToday().slice(0, 10);
var boy = gs.beginningOfYesterday().slice(0, 10);
var bot2 = gs.beginningOfToday();
var boy2 = gs.beginningOfYesterday();
gs.log("-}> BOT: " + bot);
gs.log("-}> BOY: " + boy);
gs.log("-}> BOT2: " + bot2);
gs.log("-}> BOY2: " + boy2);
gs.log("-}> TODAY: " + gs.dateGenerate(gs.beginningOfToday().slice(0,10),'06:30:00'));
gs.log("-}> YESTERDAY: " + gs.dateGenerate(gs.beginningOfYesterday().slice(0,10),'06:30:00'));
gs.log("-}> TODAY2: " + gs.dateGenerate(das[0],'06:30:00'));
gs.log("-}> YESTERDAY2: " + gs.dateGenerate(dae[0],'06:30:00'));
Now, here's the result:
Notice that all the gs.dateGenerate() calls are completely ignoring the second parameter!
Why?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-02-2016 07:40 AM
That's the time zone. As I mentioned in the previous post, the inputs are in local time, the output in GMT. I see that you're in U.S. EDT, so 06:30 EDT = 10:30 GMT.
If that's the case, your output looks OK to me.