Page 1 of 1

Filter between dates

PostPosted: Thu May 02, 2019 11:15 pm
by m0nkey
Ok. i throw up the white flag for now. just need a little help if anyone can assist.

I have a query that runs great in mysql and in vici filters i can run them separate. if i add the AND operator, it doesnt return anything in filter preview but i know it will return something, as i can see plenty in mysql directly. i think its a fairly basic query but its kicking my a$$.

my query is as follows in mysql:

select count(*) from vicidial_list where date(entry_date) > date(CONCAT(DATE_ADD(CURDATE(), INTERVAL -30 DAY),' ',CURTIME())) and date(entry_date) < date(CONCAT(DATE_ADD(CURDATE(), INTERVAL -15 DAY),' ',CURTIME()));

basically just want the leads from 15 to 30 days from today.

i have tried this too:
date(entry_date) between date(CONCAT(DATE_ADD(CURDATE(), INTERVAL -30 DAY),' ',CURTIME())) and date(CONCAT(DATE_ADD(CURDATE(), INTERVAL -15 DAY),' ',CURTIME()))

and this:
date(entry_date) > date(CONCAT(DATE_ADD(CURDATE(), INTERVAL -30 DAY),' ',CURTIME())) and date(entry_date) < date(CONCAT(DATE_ADD(CURDATE(), INTERVAL -15 DAY),' ',CURTIME()))

and even this crazy thing:
((date(entry_date) in (select date(entry_date) from vicidial_list where date(entry_date) < date(CONCAT(DATE_ADD(CURDATE(), INTERVAL -15 DAY),' ',CURTIME()))))
and
(date(entry_date) in (select date(entry_date) from vicidial_list where date(entry_date) > date(CONCAT(DATE_ADD(CURDATE(), INTERVAL -30 DAY),' ',CURTIME())))))


I've thrown in more parenthesis in these things than i can express. If anyone has an idea on how to get more than 15 days but less than 30, please throw me a bone.

thanks ahead.

Re: Filter between dates

PostPosted: Fri May 03, 2019 5:46 am
by blackbird2306
Put this into your filter SQL field:

Code: Select all
(DATE_SUB(`entry_date`, INTERVAL -15 DAY) <= CURDATE() AND DATE_SUB(`entry_date`, INTERVAL -30 DAY) >= CURDATE())


These both conditions are logically different:
m0nkey wrote:basically just want the leads from 15 to 30 days from today.

which means >= 15 and <= 30 (in my example I assumed you mean this one)
but
m0nkey wrote:If anyone has an idea on how to get more than 15 days but less than 30, please throw me a bone.

means: >15 and <30