Hi,
This seems so basic that I’m at my wits end and don’t understand why I can’t get this query to work in a grid. I need to know how many people were hired and fired in a given date range. When I use the SQL builder and use regular dates (as I did in the Hireddates line below), the query works as expected. But as soon as I make the dates into variables (so I can use it in the grid), the query no longer shows a 1 for the ‘hired’ folks anymore - it runs fine with no errors, but the Hired column is blank. Here is the query:
SELECT
name,
location,
HireDate,
termed,
if(termed is null,0,1) as ended,
if((HireDate BETWEEN ‘2018-03-04’ AND ‘2018-03-16’),1,null) as Hireddates,
if((HireDate BETWEEN ‘[recrut_start]’ AND ‘[recrut_end]’),1,null) as Hired
FROM
sec_users
WHERE
(termed >= ‘[recrut_start]’) AND (termed <= ‘[recrut_end]’) OR
(HireDate >= ‘[recrut_start]’) AND (HireDate <= ‘[recrut_end]’)
The query pulls the correct record count, so the variables are working to the best of my knowledge. Maybe there’s an easier way of doing this, but the last two columns of the query are identical other than the dates being written out vs using variables… and when I run the grid, and enter the same dates to meet the variable prompts, Hireddates shows a 1 for the folks that were hired between those dates, but ‘Hired’ is all null. I’ve tried converting the HireDate and the variables to Unix time, and still get the same result.
Any idea what I’m missing here? It’s driving me absolutely nuts…
TIA…Mark.