-
-
Save kenjosling/cb30ae75cde554b0bdcfd1805bc00fba to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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