Trying to add hours to date for filter expression

Posted by Community Admin on 04-Aug-2018 16:55

Trying to add hours to date for filter expression

All Replies

Posted by Community Admin on 18-Jul-2016 00:00

I've created a custom content type for a cafeteria menu, and in the back end the user selects a Date when creating that day's menu. The current day's menu needs to be displayed until 3 a.m. the next day (for example, the menu for Monday, July 18 is available until 3 a.m. on Tuesday, July 19). After 3 a.m. I no longer want the previous day's menu to display but keep the rest in the list live. See the attached screen shot to see the set up.

In the advanced settings for the menu widget I've tried the following filter expression but am getting an error:

Visible = true AND Status = Live AND Date >= DateTime.Today.AddHours(27)

This actually works if I write "Visible = true AND Status = Live AND Date > DateTime.Today," but the error appears when I try to add "AddHours" to the expression.

Is there another way to write this expression that won't throw an error?

This thread is closed