<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kit Menke&#039;s Blog &#187; Search</title>
	<atom:link href="http://kitmenke.com/blog/tag/search/feed/" rel="self" type="application/rss+xml" />
	<link>http://kitmenke.com/blog</link>
	<description>Experiences with SharePoint, web development, and programming</description>
	<lastBuildDate>Fri, 20 Aug 2010 14:19:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Relative Dates in JavaScript</title>
		<link>http://kitmenke.com/blog/2010/01/23/relative-dates-in-javascript/</link>
		<comments>http://kitmenke.com/blog/2010/01/23/relative-dates-in-javascript/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 03:37:41 +0000</pubDate>
		<dc:creator>Kit</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Example]]></category>
		<category><![CDATA[Search]]></category>

		<guid isPermaLink="false">http://kitmenke.com/blog/?p=183</guid>
		<description><![CDATA[I was developing an input form for a search when I came across the need to allow the user to filter items using a date range. I had two input boxes where the user could enter a start and an end date. For some of the most common date ranges, I decided to create links [...]]]></description>
			<content:encoded><![CDATA[<p>I was developing an input form for a search when I came across the need to allow the user to filter items using a date range. I had two input boxes where the user could enter a start and an end date. For some of the most common date ranges, I decided to create links that could be clicked to auto-populate the start/end date textboxes. For example, searching for items that were created last week or last month. Using JavaScript&#8217;s Date object, I was able to put together some nice examples.</p>
<p><span id="more-183"></span></p>
<p>First, the setup. I needed two text boxes to hold the start/end dates and then wanted the user to click links to auto-populate them with some relative dates:</p>
<pre lang="html4strict" escaped="true">&lt;a href="javascript: void(0);" onclick="return setRelativeDate('today')"&gt;Today&lt;/a&gt;

&lt;label for="txtStartDate"&gt;Start Date:&lt;/label&gt;&lt;input id="txtStartDate" type="text" /&gt;
&lt;label for="txtEndDate"&gt;End Date:&lt;/label&gt;&lt;input id="txtEndDate" type="text" /&gt;</pre>
<p>Then to figure out how to calculate the dates using JavaScript. Here are the examples.. starting out easy with <strong>Today</strong>&#8216;s date. When creating a new Date object, it is automatically initialized to the current day and time:</p>
<pre lang="javascript" escaped="true">var today = new Date();
txtStartDate.value = getShortDateString(today);
txtEndDate.value = txtStartDate.value;</pre>
<p><strong>Yesterday </strong>is Today -1:</p>
<pre lang="javascript" escaped="true">var yesterday = new Date();
yesterday.setDate(yesterday.getDate()-1);
txtStartDate.value = getShortDateString(yesterday);
txtEndDate.value = txtStartDate.value;</pre>
<p><strong>This Week </strong>is a little more complicated. getDate() returns the day of the month (1-31) and getDay() returns the day of the week (0-6).</p>
<pre lang="javascript" escaped="true">var thisWeek = new Date();
// set the date to most recent Sunday
thisWeek.setDate(thisWeek.getDate() - thisWeek.getDay());
txtStartDate.value = getShortDateString(thisWeek);
// set the date to last week's Saturday
thisWeek.setDate(thisWeek.getDate() + 6);
txtEndDate.value = getShortDateString(thisWeek);</pre>
<p><strong>Last Week</strong> is pretty similar to this week. I think the hardest part for me is the function names getDate and getDay. I always was getting them confused and thought that they should have been more specific&#8230; like getWeekDay and getMonthDay or something.</p>
<pre lang="javascript" escaped="true">var lastWeek = new Date();
// set the date to last week's Sunday
lastWeek.setDate(lastWeek.getDate() - lastWeek.getDay() - 7);
txtStartDate.value = getShortDateString(lastWeek);
// set the date to last week's Saturday
lastWeek.setDate(lastWeek.getDate() + 6);
txtEndDate.value = getShortDateString(lastWeek);</pre>
<p>The main difficulty I had with <strong>This Month</strong> was how to figure out the last day of the month. Luckily, if you can figure it out by selecting the first of next month and then subtracting a day.</p>
<pre lang="javascript" escaped="true">var lastDayOfThisMonth = new Date();
// go to the next month
var nextMonth = lastDayOfThisMonth.getMonth() + 1;
lastDayOfThisMonth.setMonth(nextMonth);
// go to the last day of the previous month (this month)
lastDayOfThisMonth.setDate(0);
txtEndDate.value = getShortDateString(lastDayOfThisMonth);
lastDayOfThisMonth.setDate(1);
txtStartDate.value = getShortDateString(lastDayOfThisMonth);</pre>
<p>Notice how <strong>Last Month</strong> is actually easier because you can simply move backwards a month.</p>
<pre lang="javascript" escaped="true">var lastDayOfLastMonth = new Date(); // now
lastDayOfLastMonth.setDate(0); // last day of last month            
// set the end date first
txtEndDate.value = getShortDateString(lastDayOfLastMonth);
lastDayOfLastMonth.setDate(1);
txtStartDate.value = getShortDateString(lastDayOfLastMonth);</pre>
<p>The only issue I had with <strong>This Year</strong> was I didn&#8217;t realize that  setMonth(int) took a zero based month: 0 = January &#8230; 11 = December.</p>
<pre lang="javascript" escaped="true">var lastDayOfThisYear = new Date();
lastDayOfThisYear.setMonth(11); // December
lastDayOfThisYear.setDate(31);
txtEndDate.value = getShortDateString(lastDayOfThisYear);
lastDayOfThisYear.setMonth(0); // January
lastDayOfThisYear.setDate(1);
txtStartDate.value = getShortDateString(lastDayOfThisYear);</pre>
<p>Finally, to figure out <strong>Last Year</strong> I took advantage of the setFullYear(year,month,day) function to subtract one year.</p>
<pre lang="javascript" escaped="true">var lastDayOfLastYear = new Date();
// -1 means last year
// 11 means December and there always is a 31st of december
var thisYear = lastDayOfLastYear.getFullYear();
lastDayOfLastYear.setFullYear(thisYear - 1, 11, 31);
txtEndDate.value = getShortDateString(lastDayOfLastYear);
lastDayOfLastYear.setMonth(0); // January
lastDayOfLastYear.setDate(1); // 1st
txtStartDate.value = getShortDateString(lastDayOfLastYear);</pre>
<p>See all of it together in the <a href="http://kitmenke.com/blog/wp-content/uploads/2010/01/javascript_relativedates.html">complete demo</a>.</p>
<p>References:</p>
<ul>
<li><a href="http://www.w3schools.com/jS/js_obj_date.asp">JavaScript Date Object </a></li>
<li><a href="http://www.w3schools.com/jsref/jsref_obj_date.asp">JavaScript Date Object Full Reference</a></li>
</ul>
<img src="http://kitmenke.com/blog/?ak_action=api_record_view&id=183&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kitmenke.com/blog/2010/01/23/relative-dates-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enterprise Search and SharePoint</title>
		<link>http://kitmenke.com/blog/2009/05/21/enterprise-search-sql-and-sharepoint/</link>
		<comments>http://kitmenke.com/blog/2009/05/21/enterprise-search-sql-and-sharepoint/#comments</comments>
		<pubDate>Thu, 21 May 2009 15:48:28 +0000</pubDate>
		<dc:creator>Kit</dc:creator>
				<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[Enterprise Search]]></category>
		<category><![CDATA[ESSQL]]></category>
		<category><![CDATA[MOSS2007]]></category>
		<category><![CDATA[Search]]></category>

		<guid isPermaLink="false">http://kitmenke.com/blog/?p=18</guid>
		<description><![CDATA[I&#8217;ve learned a couple of different things from messing with Enterprise Search and SharePoint. A lot of this has to do with the initial setup and how different crawls affect the index. What this assumes: You know how to get to Central Admin and the Search Admin screens Any URLs below you will have to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve learned a couple of different things from messing with Enterprise Search and SharePoint. A lot of this has to do with the initial setup and how different crawls affect the index.</p>
<p>What this assumes:</p>
<ul>
<li>You know how to get to Central Admin and the Search Admin screens</li>
<li>Any URLs below you will have to replace &#8220;centraladmin&#8221; with your own server ip</li>
<li>The place where you can run incremental or full crawls is:
<p>http://centraladmin/ssp/admin/_layouts/listcontentsources.aspx</li>
</ul>
<p>Metadata properties:</p>
<ul>
<li>In order to have more columns to search, you must add them to the &#8220;Metadata&#8221;  in the ssp
<p>http://centraladmin/ssp/admin/_layouts/schema.aspx</li>
<li>Any metadata property has a 64 character limit when querying using Enterprise Search SQL (ESSQL)</li>
<li>In order for a column to show up in the Add Mapping dialog an  <strong><span style="text-decoration: underline;">INCREMENTAL</span></strong> crawl is required (column existed and just  didn&#8217;t have data in&#8230; added some data to the list making sure to populate the  new fields and then ran an incremental)</li>
<li>Adding a Managed Property requires a <strong><span style="text-decoration: underline;">FULL</span></strong> crawl in  order to populate the data in that field</li>
</ul>
<p>Search visibility:</p>
<ul>
<li>If a site has Search Visibility disabled, it will show up as a warning in  the crawl log. LISTS DO NOT</li>
<li>Changing a list&#8217;s Search Visibility (in advanced settings) will require a  <strong><span style="text-decoration: underline;">INCREMENTAL</span></strong> (full is not required) crawl in order to  start showing up in search results</li>
</ul>
<p>Search scopes:</p>
<ul>
<li>Changing an existing search scope requires you to update the scope  again<br />
Go back to Central Admin -&gt; ssp -&gt; Search Settings -&gt;  Start Updating<br />
After clicking Update&#8230; it almost always goes from 0% to 100%  after a while&#8230; no in between</li>
<li>Changing scopes does not require an incremental or full crawl (you simply  need to update the scope again) see above</li>
<li>For a search scope, to have it include list items your scope should have a &#8220;folder&#8221; with a value like (encoded url with trailing slash):
<p>http://moss/sitecollection/subsite/Lists/My%20List%20Name/</li>
</ul>
<p>Also, here is some very <strong>unhelpful</strong> microsoft documentation:<br />
<a href="http://msdn.microsoft.com/en-us/library/ms493660.aspx">http://msdn.microsoft.com/en-us/library/ms493660.aspx</a></p>
<p>Leave a comment if you have questions!</p>
<img src="http://kitmenke.com/blog/?ak_action=api_record_view&id=18&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://kitmenke.com/blog/2009/05/21/enterprise-search-sql-and-sharepoint/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
