I need to run a query that selects records whose date is not within a date range.
More exactly, I need the records whose date is not found among their own date and 5 days later.
For example, suppose a.DateSubmitted contains this date "2016-07-10 00:00:00". I want to select the record only if a.DateSubmitted is not between 2016-07-10 00:00:00 and 2016-07-15 00:00:00.
How do I do that?
I have the following code, but It does not work. The browser returns me only this: Array (), nothing more.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query
->select('a.SubmissionId, a.DateSubmitted, b.SubmissionId, b.FieldName, b.FieldValue')
->from($db->quoteName('#__rsform_submissions', 'a'))
->join('INNER', $db->quoteName('#__rsform_submission_values', 'b') . ' ON (' . $db->quoteName('a.SubmissionId') . ' = ' . $db->quoteName('b.SubmissionId') . ')')
->where($db->quoteName('a.DateSubmitted') . ' NOT BETWEEN \'' . $db->quoteName('a.DateSubmitted') . '\' AND \'' . date( $db->quoteName('a.DateSubmitted') , strtotime('+5 day')) . '\' ');