A customer asked me yesterday if it’s possible to create a view which shows only the announcements of the last three days and the ones that aren’t yet expired.
You know that you can add filter conditions on a view but that piece of functionality is very limited.
Default you have two date columns ‘created’ and ‘expire’, both columns are Dat Time types.
It’s not possible to type this in one of your filter view conditions:
created is greater or equal to [today] + day(3)
Sharepoint will raise an error on the [today] + day(3) part.
You can easily solve this by creating a calculated column of type DateTime and named it for example: Hot News Expire.
In the formula textbox of the column enter the follow formula: [created] + day(3). It’s possible to use more "excel-like functions" in a calculated field than in the filter options of a view or the filter of the Content Query Webpart.
Every announcement has now an extra column with a DateTime value on which you can filter!
So, no coding is necessary, just some extra configuration on your announcement list.