FilterExpression - Retrieval by Date Range
I have seen mixed responses throughout the forums on the use of the FilterExpression.
I am trying to make sure that a News List includes only news articles that are between two dates, the DateOfPublication and the ExpirationDate - both custom fields.
In the NewsFrontendList's FilterExpression attribute, I entered the following condition:
Visible = true AND Status = Live AND DateOfPublication <= DateTime.UtcNow AND (ExpirationDate = NULL OR ExpirationDate > DateTime.UtcNow)
Visible = true AND Status = Live AND DateOfPublication <= DateTime.UtcNow AND (ExpirationDate < (1/1/1900 23:59) OR ExpirationDate > DateTime.UtcNow)
Hi Deon,
You have been given an answer in the support ticket you have opened. I will paste the answer below:
In order to check if the ExpirationDate field has been populated with a value or not in the FilterExpression you can modify your filter like so:
Visible = true AND Status = Live AND DateOfPublication <= DateTime.UtcNow AND (!ExpirationDate.HasValue
OR ExpirationDate > DateTime.UtcNow)
Regards,Thanks. That worked perfectly.