How to select a range of dates

How to fix a key() expects parameter to be array error when selecting a date range in ChronoForms.

Overview

The error occurs because the date values passed to the query are not in the correct format, causing a null parameter where an array is expected.
Ensure the date strings are converted to valid MySQL date format before using them in the query.

Answered
Connectivity v6
Ni NickOg 08 May, 2019
Hi
​
I am trying to select data for a range of dates using
​
How to select a range of dates image 1
​
{ data } shows those two nmDate values as [nmDateFrom] => 2019-01-01 and [nmDateTo] => 2019-01-31
bur when i run the selection I get
​

0 - key() expects parameter 1 to be array, null given


​
It works fine with a single date selection
​
How to select a range of dates image 2
​
​
​
SELECT `mdlMbrReceipts`.`idReceipt` AS `mdlMbrReceipts.idReceipt`, `mdlMbrReceipts`.`feeYear` AS `mdlMbrReceipts.feeYear`, `mdlMbrReceipts`.`feeToPay` AS `mdlMbrReceipts.feeToPay`, `mdlMbrReceipts`.`receiptType` AS `mdlMbrReceipts.receiptType`, `mdlMbrReceipts`.`user_id` AS `mdlMbrReceipts.user_id`, `mdlMbrReceipts`.`lastname` AS `mdlMbrReceipts.lastname`, `mdlMbrReceipts`.`firstname` AS `mdlMbrReceipts.firstname`, `mdlMbrReceipts`.`dateReceived` AS `mdlMbrReceipts.dateReceived`, `mdlMbrReceipts`.`accountPaid` AS `mdlMbrReceipts.accountPaid`, `mdlMbrReceipts`.`datePaid` AS `mdlMbrReceipts.datePaid`, `mdlMbrReceipts`.`payReceivedById` AS `mdlMbrReceipts.payReceivedById`, `mdlMbrReceipts`.`paidBy` AS `mdlMbrReceipts.paidBy` FROM `u3a_00_receiptsmembership` AS `mdlMbrReceipts` WHERE `mdlMbrReceipts`.`datePaid` >= '2019-01-01' ORDER BY `mdlMbrReceipts.datePaid` DESC, `mdlMbrReceipts.paidBy` ASC, `mdlMbrReceipts.idReceipt` ASC LIMIT 20;
​
I have tried to change those date selectors to mySQL dates but the same problem. And I have tried with just that dateTo value. Again - on its own - fine! and the SQL above woth both dates in works fine with phpMyAdmin
​
Any suggestions??
Regards
​
Nick
Ni NickOg 08 May, 2019
Answer
1 Likes
Doh! Fixed - changing the date strings to mySQL dates was the solution . Found a bug in my logic and now works fine just after I posted the above.
​
Max - drop the post if appropriate.
​
Nick
🙄😑
This topic is locked and no more replies can be posted.