Skip to content

Instantly share code, notes, and snippets.

@kenjosling kenjosling/bot4.js Secret
Last active Jul 8, 2018

Embed
What would you like to do?
function getDateFilter(dateRange) {
if(!dateRange) return "";
var chrono = require('chrono-node');
var dateFormat = require('dateformat');
var dateString = chrono.parseDate(dateRange.entity).toDateString();
var date = dateFormat(new Date(dateString), "isoUtcDateTime");
if(dateRange.entity.toLowerCase().indexOf("last") >= 0) {
return " and CreateDate gt datetime'" + date + "'";
}
if(dateRange.entity.toLowerCase().indexOf("before") >= 0) {
return " and CreateDate lt datetime'" + date + "'";
}
if(dateRange.entity.toLowerCase().indexOf("after") >= 0) {
return " and CreateDate gt datetime'" + date + "'";
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.