Details
-
Type: Bug
-
Status: Open
-
Priority: Major
-
Resolution: Unresolved
-
Affects Version/s: 4.7.16
-
Fix Version/s: None
-
Component/s: CiviReport, Core CiviCRM
-
Labels:None
-
Versioning Impact:Patch (backwards-compatible bug fixes)
-
Documentation Required?:None
-
Funding Source:Needs Funding
-
Verified?:No
Description
for example:
- open the bookkeeping transaction report
- set transaction date to "today"
- run search and compare with transactions processed during the course of the day – many will be absent.
This is because in CRM_Report_Form::dateClause() we strip out the time value from dates, which means our date clause looks like:
WHERE ( trxn_date >= 20170214 ) AND ( trxn_date <= 20170214 )
Any transaction that happened during the day, aside from 12:00am, would be excluded from that query. The date clause should look like:
WHERE ( trxn_date >= 20170214 ) AND ( trxn_date <= 20170214235959 )
here is where the problem is (along with the lines below it for the $to value)
https://github.com/civicrm/civicrm-core/blob/master/CRM/Report/Form.php#L2021
interestingly, before that code is run, we call getFromTo(), which properly sets the correct $toTime. basically – we're doing the right thing by setting the $toTime and then immediately after are stripping it out.
the clause conditions on CRM_Utils_Type::T_DATE, but there's no equivalent type for T_DATETIME (there is T_TIME and T_TIMESTAMP, but neither handle the data the way we need it). so I think the question is – why do we strip out the time from the date clauses to begin with? I don't see the rationale behind why that was implemented.
I've marked this major, as it has the potentially to significantly affect reporting results that use date fields.