Silverstripe: DataObject Compare Date

We want to show the events which key date are after the current date.

Below function is not correct.

The where clause is MySQL. MySQL has a function CURDATE() that returns the DATE part of the current time, so no need to generate it yourself. Also, date is a reserved sql word, so it need to escape it with backticks.

For further info, please refer Date and time functions in the mySQL manual

Or

The correct filter function to compare date for SilverStripe is:

The filter function to find current date is between the start date and end date for SilverStripe is:

Leave a Reply

Your email address will not be published. Required fields are marked *

CAPTCHA