locked
Customized SharePoint List Filtering Condition RRS feed

  • Question

  • Hi,

    I would like to set a filtering condition within the fixed variable date under SharePoint TeamSite List view. How could I achieve it?

    As far as the condition is allowed like [Today] or [Me], my request is to filter those filtered list from 6AM to 5PM GMT+8 everyday according to the creation date.

    what's the expression to get the result.

    Tuesday, June 19, 2012 5:09 PM

Answers

  • Hi lincky,

    Based on your description, you cannot achieve this through out-of-the-box in filter, as parvez  said, we can use custom data view web part through SharePoint Designer. When you insert a data view, right click the view, click filter to edit the filter formula.

    Here is expression of filter based on Created column(to check whether time is between 6am and 5pm, we use 24hour format to compare):

    [number(substring((ddwrt:FormatDateTime(string(@Created),1033,'H:mm')),1,3))>=6 and

    number(substring((ddwrt:FormatDateTime(string(@Created),1033,'H:mm')),1,3))<=17]

    Please check it , if there is any problem, please feel free to let me know.

    Best Regards.


    Qiao Wei

    TechNet Community Support

    Wednesday, June 20, 2012 3:18 AM
    Moderator

All replies

  • By default, SharePoint filters only by Date. You'll need SharePoint designer and either edit that existing view or create a DVWP of that list with appropriate filter. Whichever option you choose, you'll need to add the following "attribute" to the CAML query for the DateTime field being filtered.

    IncludeTimeValue=True

    This will allow you to get the filter to include, well... time. As for the GMT+8, I *think* that'll depend on whatever is the regional setting of the site is, that's what will be used in the all DateTime stamp for the records.

    I had done this before, but don't remember exactly what value of the condition looks like. If you play around it, you might be able to figure it out. Shouldn't be too difficult.

    Hope that helps...


    Pman
    http://www.pmansLab.com/

    Wednesday, June 20, 2012 2:09 AM
  • Hi lincky,

    Based on your description, you cannot achieve this through out-of-the-box in filter, as parvez  said, we can use custom data view web part through SharePoint Designer. When you insert a data view, right click the view, click filter to edit the filter formula.

    Here is expression of filter based on Created column(to check whether time is between 6am and 5pm, we use 24hour format to compare):

    [number(substring((ddwrt:FormatDateTime(string(@Created),1033,'H:mm')),1,3))>=6 and

    number(substring((ddwrt:FormatDateTime(string(@Created),1033,'H:mm')),1,3))<=17]

    Please check it , if there is any problem, please feel free to let me know.

    Best Regards.


    Qiao Wei

    TechNet Community Support

    Wednesday, June 20, 2012 3:18 AM
    Moderator
  • thanks so much~ appreciated
    Saturday, September 21, 2013 1:44 PM
  • Thanks so much as well, :)
    Saturday, September 21, 2013 1:45 PM