More in this section
Forums / Developing with Sitefinity / Trying to add hours to date for filter expression

Trying to add hours to date for filter expression

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
1 posts, 0 answered
  1. Andrew
    Andrew avatar
    1 posts
    Registered:
    06 Mar 2016
    18 Jul 2016
    Link to this post

    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?

1 posts, 0 answered