Assuming the date format is fixed to yyyy-mm-dd then your best bet is probably converting the partial date to a real date.
- If the filter value has more than 7 characters assume it is year and month and parse it accordingly. Create two dates, first day of the month (
filterStartDate
) and last day of the month (filterEndDate
). You can have a look there to do that. With those two dates you will be able to mimic a contains
with something like :
Predicate
.create('startDate', '>=', filterStartDate)
.or( 'startDate', '<', filterEndDate);
- If the filter value has less than 7 characters assume it is only the year. Parse the year (
filterYear
) and do something like :
Predicate
.create('startDate', '>=', new Date(Date.UTC(filterYear, 0, 1)))
.or( 'startDate', '<', new Date(Date.UTC(filterYear, 11, 30)));
Of course if the filter value is a full date then look for this date.