Results filtered by Date Range - Even WebSearchResults

Feb 27, 2009 at 8:19 PM
Edited Feb 27, 2009 at 8:19 PM
Well, that's a few hours of my life I'll never get back.

I started off trying to get the Scoring=Date to work on Web Results, as it does with News, Blogs, etc. - but no luck.  Seems Google's left that functionality out all together.

You can however, filter your results to only return those that were indexed within a certain date range.

The syntax goes like this:
WebSearchOptions webSearchOptions = new WebSearchOptions();
searchResults = Searcher.Search(webSearchOptions, "\"Yamaha Motorcycle\" daterange:2450958-2450968");

That also works if you just punch it into the search.  So, you dont add it as a query parameter - instead it gets embedded in the search string.

The following two links got me started:

The catch is that you need to represent the date range as a Julian date. 

A function to do this can be found here:

And you're away!

Simple Sales Tracking
Feb 27, 2009 at 8:40 PM
Edited Feb 27, 2009 at 8:41 PM
Should mention also - Google doesnt take into account anything after the '.' in a Julian date, which represents Hours, Seconds, Minutes...  So, when you're creating the dates, round the number to 0 decimal places.

For example, the following line would return everything indexed over the last 24 hours:


WebSearchOptions webSearchOptions = new WebSearchOptions();

string searchTerms;

searchTerms =
"\"Yamaha Motorcycle\" daterange:" + Math.Round(GetJulianDate(DateTime.UtcNow.AddDays(-1)), 0) + "-" + Math.Round(GetJulianDate(DateTime.UtcNow), 0);

SearchResults searchResults = Searcher.Search(webSearchOptions, searchTerms);