2010-10-27

DateTime filter in SharePoint 2010 List View

The way i got around this, was to pipe the result from the DateTimeControl to a HiddenField using inline code.

Added these controls
< SharePoint:DateTimeControl runat="server" id="FilterFrom" DateOnly="True" LocaleId="3081" SelectedDate="2010-10-01"/>
< asp:HiddenField runat="server" id="FilterFromFixed" />

Had this query
< Where>
< Geq>
< FieldRef Name="FirstDay"/>
< Value Type="DateTime">{FilterFromFixed}< /Value>
< /Geq>
< /Where>

Added this to web.config
< PageParserPath VirtualPath="/Lists/YourList/YourView.aspx" CompilationMode="Always" AllowServerSideScript="true" />

Then had this inline code in the view
< script runat="server">
protected void Page_Load(object sender, EventArgs e) {
FilterFromFixed.Value = FilterFrom.SelectedDate.ToString("yyyy-MM-dd");
}
< /script>