Query records in the moss list within two date ranges

Source: Internet
Author: User

Add a list on the page and convert it to XLST format.

Step 1: Add two parameters to the list (right-click the list): pstartdate and penddate;

 

 

 

 

Step 2: After the parameters are created, goCodeView: Find the line (CTRL + F:

<XSL: template match = "/" xmlns: x = "http // www.w3.org/2001/xmlschema"

 

Replace the following code with the above line:

<XSL: template match = "/" xmlns: x = "http // www.w3.org/2001/xmlschema"

Xmlns: D = "http://schemas.microsoft.com/sharepoint/dsp"

Xmlns: ASP = "http://schemas.microsoft.com/ASPNET/20"

Xmlns: _ designer = "http: schemas.microsoft.com/webparts/v2/dataview/designer"

Xmlns: SharePoint = "Microsoft. Sharepoint. webcontrols"

>

<Table border = "0" width = "100%" cellpadding = "5" cellspacing = "0">

<Tr valign = "TOP">

<TH class = "MS-Vl" nowrap = ""> query start date: </Th>

<TH class = "MS-ku" nowrap = "">

<SharePoint: datetimecontrol runat = "server" id = "datetimecontrol1"

Dateonly = "true" localeid = "2052" selecteddate = "{$ pstartdate}"/> </Th>

<TH class = "MS-Vl" nowrap = ""> query end date: </Th>

<TH class = "MS-ku" nowrap = "">

<SharePoint: datetimecontrol runat = "server" id = "datetimecontrol2"

Dateonly = "true" localeid = "2052" selecteddate = "{$ penddate}"/> </Th>

<TH class = "MS-ku" nowrap = "">

<SCRIPT type = "text/JavaScript">

Function postdateback (){

VaR vcalenderdate = Document. getelementbyid (g_strdatetimecontrolids

["Datetimecontrol1"]);

VaR vstr1 = vcalenderdate. value;

Vstr1 = vstr1.replace (// G ,"-");

VaR vdate = Document. getelementbyid (g_strdatetimecontrolids

["Datetimecontrol2"]);

VaR vstr2 = vdate. value;

Vstr2 = vstr2.replace (// G ,"-");

VaR TargetUrl = removequeryparameterfromurl (window. Location. href, "calendardate ");

TargetUrl = removequeryparameterfromurl (window. Location. href, "date ");

TargetUrl = sturlsetvar2 (TargetUrl, "calendardate", vstr1 );

TargetUrl = TargetUrl + "& amp; Date =" + vstr2;

Window. Location. href = TargetUrl;

}

</SCRIPT> <input name = "button1" type = "button" value = "query" onclick = "postdateback ();"/>

 

Finally, we will see:

Then, you can set filtering conditions for the list.

In addition, if you add a calendar control to the page (add this line to the Code)

<SharePoint: spdatepickercontrol id = "dpc1" runat = "server" langid = "2052" localeid = "2052"/>)

Click the calendar control twice, select two dates, and click the start query button above to achieve the same effect.

Code testing is successful.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.