Filter items from last week (begin Monday start of week)

I would like to dynamically filter to display items from last week (Monday is the first day of the week).  Is this possible to do in XSLT? If so, how?  
LVL 6
miketech99Asked:
Who is Participating?
 
kmartin7Connect With a Mentor Commented:
In your XSL, include it like the following:

<xsl:import href="date.day-in-week.template.xsl"/> (make sure path is correct).

Now you call it like:

<xsl:call-template name="date:day-in-week"/>

It will return the day of the week based on date. You'll need to test to ensure what value is returned (1 through 7). Like I mentioned, the documentation states Sunday = 1, Saturday = 7; but my testing is Monday = 1, Sunday = 7.
0
 
kmartin7Commented:
It is possible, but quite complex. I would start at:

http://www.exslt.org/date/functions/day-in-week/index.html

It is easy to implement the template call, but not easy to determine how best to integrate into your solution. Also, it has been my experience with this template that the documentation is incorrect:

"The numbering of days of the week starts at 1 for Sunday, 2 for Monday and so on up to 7 for Saturday."

Actual implementation has Monday as 1 and Sunday as 7, as an FYI.

Hope this helps,

kmartin7
0
 
miketech99Author Commented:
Thanks so much for your input.  I've been struggling with this for months.
Below is my current dataview/xslt.
You don't have to do it for me how would I include that template? I'm using SharePoint Designer--is there something else I should use instead to add the template?  

<WebPartPages:DataFormWebPart runat="server" SuppressWebPartChrome="False" Description="" PartImageSmall="" DataSourceID="" MissingAssembly="Cannot import this Web Part." ListName="{CF9A7BB1-CBB6-4881-A6B7-2870FD8D512E}" FrameType="Default" ConnectionID="00000000-0000-0000-0000-000000000000" DetailLink="" ExportControlledProperties="True" IsVisible="True" AllowRemove="True" AllowEdit="True" ID="g_d5522212_5322_49cc_89ae_391de9bff747" Dir="Default" FrameState="Normal" DisplayName="Time Log" ViewContentTypeId="" AllowConnect="True" PageSize="-1" Default="FALSE" AllowMinimize="True" IsIncludedFilter="" ShowWithSampleData="False" HelpMode="Modeless" ExportMode="All" ViewFlag="0" Title="Last Week - Use to record/modify ONLY last week project hours (Mon-Sun)" HelpLink="" AllowHide="True" AllowZoneChange="True" PartOrder="1" UseSQLDataSourcePaging="True" PartImageLarge="" IsIncluded="True" NoDefaultStyle="TRUE" __MarkupType="vsattributemarkup" __WebPartId="{D5522212-5322-49CC-89AE-391DE9BFF747}" __AllowXSLTEditing="true" WebPart="true" Height="" Width=""><DataSources>
<SharePoint:SPDataSource runat="server" DataSourceMode="List" SelectCommand="&lt;View&gt;&lt;Query&gt;&lt;Where&gt;&lt;And&gt;&lt;Eq&gt;&lt;FieldRef Name=&quot;Author&quot;/&gt;&lt;Value Type=&quot;Integer&quot;&gt;&lt;UserID/&gt;&lt;/Value&gt;&lt;/Eq&gt;&lt;Eq&gt;&lt;FieldRef Name=&quot;Week&quot;/&gt;&lt;Value Type=&quot;DateTime&quot;&gt;2009-04-27T08:27:25Z&lt;/Value&gt;&lt;/Eq&gt;&lt;/And&gt;&lt;/Where&gt;&lt;/Query&gt;&lt;/View&gt;" UseInternalName="True" ID="Time_x0020_Log2"><SelectParameters><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="CF9A7BB1-CBB6-4881-A6B7-2870FD8D512E" Name="ListID"></WebPartPages:DataFormParameter>
</SelectParameters><UpdateParameters><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="CF9A7BB1-CBB6-4881-A6B7-2870FD8D512E" Name="ListID"></WebPartPages:DataFormParameter>
</UpdateParameters><InsertParameters><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="CF9A7BB1-CBB6-4881-A6B7-2870FD8D512E" Name="ListID"></WebPartPages:DataFormParameter>
</InsertParameters><DeleteParameters><WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="CF9A7BB1-CBB6-4881-A6B7-2870FD8D512E" Name="ListID"></WebPartPages:DataFormParameter>
</DeleteParameters>
</SharePoint:SPDataSource>
</DataSources>
<ParameterBindings>
	<ParameterBinding Name="ListID" Location="None" DefaultValue="CF9A7BB1-CBB6-4881-A6B7-2870FD8D512E"/>
	<ParameterBinding Name="dvt_apos" Location="Postback;Connection"/>
	<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
	<ParameterBinding Name="Today" Location="CAMLVariable" DefaultValue="CurrentDate"/>
	<ParameterBinding Name="dvt_1_form_insertmode" Location="Postback;Connection"/>
</ParameterBindings>
<DataFields>@Title,Task;@StartDate,Start Time;@_EndDate,End Time;@Hours,Hours;@Week,Week;@Month,Month;@Sunday,Sunday;@Monday,Monday;@Tuesday,Tuesday;@Wednesday,Wednesday;@Thursday,Thursday;@Friday,Friday;@Saturday,Saturday;@WeekEndTotal,WeekEndTotal;@WeekStart,WeekStart;@WeekEnd,WeekEnd;@LastWeek,LastWeek;@Project,Project;@Cost,Cost;@LastWeekStartDate,LastWeekStartDate;@EstimatedCost,EstimatedCost;@SetEstim,Set Estimated Hours;@SetProje,Set Project For Next Week;@NextWeekStartDate,NextWeekStartDate;@ThisWeek,ThisWeek;@LastWeekDate,LastWeekDate;@CompareCalc,CompareCalc;@ID,ID;@ContentType,Content Type;@Modified,Modified;@Created,Created;@Author,Created By;@Editor,Modified By;@_UIVersionString,Version;@Attachments,Attachments;@File_x0020_Type,File Type;@FileLeafRef,Name (for use in forms);@FileDirRef,Path;@FSObjType,Item Type;@_HasCopyDestinations,Has Copy Destinations;@_CopySource,Copy Source;@ContentTypeId,Content Type ID;@_ModerationStatus,Approval Status;@_UIVersion,UI Version;@Created_x0020_Date,Created;@FileRef,URL Path;</DataFields>
<Xsl>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
<xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">
	<xsl:output method="html" indent="no"/>
	<xsl:decimal-format NaN=""/>
	<xsl:param name="dvt_apos">&apos;</xsl:param>
	<xsl:param name="UserID">CurrentUserName</xsl:param>
	<xsl:param name="dvt_1_form_insertmode" />
	<xsl:param name="Today">CurrentDate</xsl:param>
	<xsl:variable name="dvt_1_automode">0</xsl:variable>
	
	
	
	<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">
		<xsl:call-template name="dvt_1"/>
	</xsl:template>
	
	<xsl:template name="dvt_1">
		<xsl:variable name="dvt_StyleName">Table</xsl:variable>
		<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>
		
		
		<table border="0" width="100%" cellpadding="2" cellspacing="0">
			<tr valign="top">
				<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
					<th class="ms-vh" width="1%" nowrap="nowrap"></th>
				</xsl:if>
				<th class="ms-vh" nowrap="">Week</th>
				<!-- <th class="ms-vh" nowrap="">Start Time</th>--><th class="ms-vh" nowrap="">Project</th><th class="ms-vh" nowrap="">Monday</th>
				<th class="ms-vh" nowrap="">Tuesday</th>
				<th class="ms-vh" nowrap="">Wednesday</th>
				<th class="ms-vh" nowrap="">Thursday</th>
				<th class="ms-vh" nowrap="">Friday</th>
				<th class="ms-vh" nowrap="">Saturday</th>
				<th class="ms-vh" nowrap="">Sunday</th>
			</tr>
			<xsl:if test="not($dvt_1_form_insertmode = '1')">
				<xsl:call-template name="dvt_1.body">
					<xsl:with-param name="Rows" select="$Rows"/>
				</xsl:call-template></xsl:if>
			<xsl:call-template name="dvt_1.rowinsert">
				<xsl:with-param name="IsInsertMode">
					<xsl:if test="$dvt_1_form_insertmode = '1'">1</xsl:if>
				</xsl:with-param>
			</xsl:call-template>
		</table>
		<xsl:call-template name="dvt_1.commandfooter" />
	</xsl:template>
	<xsl:template name="dvt_1.body">
		<xsl:param name="Rows"/>
		<xsl:for-each select="$Rows">
			<xsl:call-template name="dvt_1.rowedit">
				<xsl:with-param name="Pos" select="concat('_', position())" />
			</xsl:call-template>
			
		</xsl:for-each>
	</xsl:template>
	<xsl:template name="dvt_1.rowedit">
		<xsl:param name="Pos" />
		<tr>
			<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
				<td class="ms-vb" width="1%" nowrap="nowrap">
					<span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="edit"></span>
				</td>
			</xsl:if>
			<td class="ms-vb">
				<xsl:value-of select="ddwrt:FormatDate(string(@Week) ,1033 ,1)"/>
			</td>
			<!--<td class="ms-vb">
				<SharePoint:FormField runat="server" id="ff2{$Pos}" ControlMode="Edit" FieldName="StartDate" ItemId="{@ID}" __designer:bind="{ddwrt:DataBind('u',concat('ff2',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@StartDate')}"/>
				<SharePoint:FieldDescription runat="server" id="ff2description{$Pos}" FieldName="StartDate" ControlMode="Edit"/>
			</td>--><td class="ms-vb">
				<asp:Label runat="server" id="ff19{$Pos}" text="{@Project}" __designer:bind="{ddwrt:DataBind('u',concat('ff19',$Pos),'Text','','ID',ddwrt:EscapeDelims(string(@ID)),'@Project')}" />
				
				<SharePoint:FieldDescription runat="server" id="ff10description9{$Pos}" FieldName="Project" ControlMode="Edit" /></td><td class="ms-vb">
				<SharePoint:FormField runat="server" id="ff3{$Pos}" ControlMode="Edit" FieldName="Monday" ItemId="{@ID}" __designer:bind="{ddwrt:DataBind('u',concat('ff3',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Monday')}"/>
				<SharePoint:FieldDescription runat="server" id="ff3description{$Pos}" FieldName="Monday" ControlMode="Edit"/>
			</td>
			<td class="ms-vb">
				<SharePoint:FormField runat="server" id="ff4{$Pos}" ControlMode="Edit" FieldName="Tuesday" ItemId="{@ID}" __designer:bind="{ddwrt:DataBind('u',concat('ff4',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Tuesday')}"/>
				<SharePoint:FieldDescription runat="server" id="ff4description{$Pos}" FieldName="Tuesday" ControlMode="Edit"/>
			</td>
			<td class="ms-vb">
				<SharePoint:FormField runat="server" id="ff5{$Pos}" ControlMode="Edit" FieldName="Wednesday" ItemId="{@ID}" __designer:bind="{ddwrt:DataBind('u',concat('ff5',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Wednesday')}"/>
				<SharePoint:FieldDescription runat="server" id="ff5description{$Pos}" FieldName="Wednesday" ControlMode="Edit"/>
			</td>
			<td class="ms-vb">
				<SharePoint:FormField runat="server" id="ff6{$Pos}" ControlMode="Edit" FieldName="Thursday" ItemId="{@ID}" __designer:bind="{ddwrt:DataBind('u',concat('ff6',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Thursday')}"/>
				<SharePoint:FieldDescription runat="server" id="ff6description{$Pos}" FieldName="Thursday" ControlMode="Edit"/>
			</td>
			<td class="ms-vb">
				<SharePoint:FormField runat="server" id="ff7{$Pos}" ControlMode="Edit" FieldName="Friday" ItemId="{@ID}" __designer:bind="{ddwrt:DataBind('u',concat('ff7',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Friday')}"/>
				<SharePoint:FieldDescription runat="server" id="ff7description{$Pos}" FieldName="Friday" ControlMode="Edit"/>
			</td>
			<td class="ms-vb">
				<SharePoint:FormField runat="server" id="ff8{$Pos}" ControlMode="Edit" FieldName="Saturday" ItemId="{@ID}" __designer:bind="{ddwrt:DataBind('u',concat('ff8',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Saturday')}"/>
				<SharePoint:FieldDescription runat="server" id="ff8description{$Pos}" FieldName="Saturday" ControlMode="Edit"/>
			</td>
			<td class="ms-vb">
				<SharePoint:FormField runat="server" id="ff9{$Pos}" ControlMode="Edit" FieldName="Sunday" ItemId="{@ID}" __designer:bind="{ddwrt:DataBind('u',concat('ff9',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Sunday')}"/>
				<SharePoint:FieldDescription runat="server" id="ff9description{$Pos}" FieldName="Sunday" ControlMode="Edit"/>
			</td>
		</tr>
		
	</xsl:template>
	<xsl:template name="dvt_1.commandfooter"><table cellspacing="0" cellpadding="4" border="0" width="100%">
			<tr>
				<xsl:call-template name="dvt_1.formactions" />
		</tr>
		</table></xsl:template>
	<xsl:template name="dvt_1.formactions">
		<td nowrap="" class="ms-vb">
			<input type="button" value="Save" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent('__commit')}" />
		</td>
		<td nowrap="" class="ms-vb" width="99%">
			<input type="button" value="Cancel" name="btnCancel" onclick="javascript: {ddwrt:GenFireServerEvent('__cancel')}" />
		</td></xsl:template>
	<xsl:template name="dvt_1.rowinsert">
		<xsl:param name="IsInsertMode" />
		<xsl:variable name="Pos">_new</xsl:variable>
		<tr>
			<xsl:choose>
				<xsl:when test="$IsInsertMode = '1'">
					<xsl:if test="$dvt_1_automode = '1'" ddwrt:cf_ignore="1">
						<td class="ms-vb" width="1%" nowrap="nowrap">
							<span ddwrt:amkeyfield="ID" ddwrt:amkeyvalue="ddwrt:EscapeDelims(string(@ID))" ddwrt:ammode="insert"></span>
						</td>
					</xsl:if>
					<!-- <td class="ms-vb">
						<xsl:value-of select="ddwrt:FormatDate(string(@Week),1033, 5)" />
					</td> -->
					
					<td class="ms-vb">
						<SharePoint:FormField runat="server" id="ff21{$Pos}" ControlMode="New" FieldName="LastWeekStartDate" __designer:bind="{ddwrt:DataBind('i',concat('ff21',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@StartDate')}" />
						<SharePoint:FieldDescription runat="server" id="ff21description{$Pos}" FieldName="LastWeekStartDate" ControlMode="Edit" />
					</td>
					<td class="ms-vb">
						<SharePoint:FormField runat="server" id="ff22{$Pos}" ControlMode="New" FieldName="Project" __designer:bind="{ddwrt:DataBind('i',concat('ff22',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Project')}" />
						<SharePoint:FieldDescription runat="server" id="ff22description{$Pos}" FieldName="Project" ControlMode="Edit" />
					</td>
					<td class="ms-vb">
						<SharePoint:FormField runat="server" id="ff23{$Pos}" ControlMode="New" FieldName="Monday" __designer:bind="{ddwrt:DataBind('i',concat('ff23',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Monday')}" />
						<SharePoint:FieldDescription runat="server" id="ff23description{$Pos}" FieldName="Monday" ControlMode="Edit" />
					</td>
					<td class="ms-vb">
						<SharePoint:FormField runat="server" id="ff24{$Pos}" ControlMode="New" FieldName="Tuesday" __designer:bind="{ddwrt:DataBind('i',concat('ff24',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Tuesday')}" />
						<SharePoint:FieldDescription runat="server" id="ff24description{$Pos}" FieldName="Tuesday" ControlMode="Edit" />
					</td>
					<td class="ms-vb">
						<SharePoint:FormField runat="server" id="ff25{$Pos}" ControlMode="New" FieldName="Wednesday" __designer:bind="{ddwrt:DataBind('i',concat('ff25',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Wednesday')}" />
						<SharePoint:FieldDescription runat="server" id="ff25description{$Pos}" FieldName="Wednesday" ControlMode="Edit" />
					</td>
					<td class="ms-vb">
						<SharePoint:FormField runat="server" id="ff26{$Pos}" ControlMode="New" FieldName="Thursday" __designer:bind="{ddwrt:DataBind('i',concat('ff26',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Thursday')}" />
						<SharePoint:FieldDescription runat="server" id="ff26description{$Pos}" FieldName="Thursday" ControlMode="Edit" />
					</td>
					<td class="ms-vb">
						<SharePoint:FormField runat="server" id="ff27{$Pos}" ControlMode="New" FieldName="Friday" __designer:bind="{ddwrt:DataBind('i',concat('ff27',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Friday')}" />
						<SharePoint:FieldDescription runat="server" id="ff27description{$Pos}" FieldName="Friday" ControlMode="Edit" />
					</td>
					<td class="ms-vb">
						<SharePoint:FormField runat="server" id="ff28{$Pos}" ControlMode="New" FieldName="Saturday" __designer:bind="{ddwrt:DataBind('i',concat('ff28',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Saturday')}" />
						<SharePoint:FieldDescription runat="server" id="ff28description{$Pos}" FieldName="Saturday" ControlMode="Edit" />
					</td>
					<td class="ms-vb">
						<SharePoint:FormField runat="server" id="ff29{$Pos}" ControlMode="New" FieldName="Sunday" __designer:bind="{ddwrt:DataBind('i',concat('ff29',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(@ID)),'@Sunday')}" />
						<SharePoint:FieldDescription runat="server" id="ff29description{$Pos}" FieldName="Sunday" ControlMode="Edit" />
					</td>
				</xsl:when>
				<xsl:otherwise>
					<td class="ms-vb" colspan="99">
						<a href="javascript: {ddwrt:GenFireServerEvent('__cancel;dvt_1_form_insertmode={1}')}" onclick="setStartTimeNow()">insert</a>
					</td>
				</xsl:otherwise>
			</xsl:choose>
		</tr>
	</xsl:template></xsl:stylesheet>	</Xsl>
</WebPartPages:DataFormWebPart>

Open in new window

0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
kmartin7Commented:
Ahh. Sharepoint. You'll need to download the XSL files that the page I posted previously locally to your sharepoint server (or path accessible from your server). Is this possible? Otherwise, you'll have a difficult time ahead integrating into your XSL.
0
 
miketech99Author Commented:
That would be no problem. Downloaded and uploaded http://www.exslt.org/date/functions/day-in-week/date.day-in-week.template.xsl to a directory within SharePoint (relative to the source)
0
 
miketech99Author Commented:
Thanks, I was able to find another solution to my request. I am using SharePoint so I was able to create a caculated column to return items that were created  during the last week time frame.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.