Basic Sprout Report here, settings page:
{{ forms.dateTimeField({
label: "Start Date"|t,
instructions: "The start date of the date range you wish to display in your report."|t,
id: 'datetimeStartDate',
name: 'datetimeStartDate',
value: settings.datetimeStartDate is defined ? settings.datetimeStartDate : now|date_modify("-30 days")
}) }}
{{ forms.dateTimeField({
label: "End Date"|t,
instructions: "The end date of the date range you wish to display in your report."|t,
id: 'datetimeEndDate',
name: 'datetimeEndDate',
value: (settings.datetimeEndDate is defined ? settings.datetimeEndDate : now)
}) }}
Results page:
{% set purchases = craft.entries()
.section('purchases')
.limit(null)
%}
{% if settings.datetimeStartDate and settings.datetimeEndDate %}
{% set purchases = purchases.postDate('and, >= ' ~ settings.datetimeStartDate.date ~ ', <= ' ~ settings.datetimeEndDate.date)
%}
{% endif %}
I am getting the following PHP error:
PHP Notice – yii\base\ErrorException Undefined property: DateTime::$date
I have copied the datetime fields directly from the example docs, and tested the results template code with hardcoded dates, which works fine, but passing dates this way does not work.