Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am looking for a way to save a search that includes a relative date. Specifically I am looking for a way to save a search that matches files that have a modification date that is 7 days ago.

I have read the Windows Search Advanced Query Syntax document and I am not seeing a way to say 7 days ago.

The numbers and ranges section does mention that relative dates are possible. The problem is that the relative dates described there do not fit the criteria I need. The lastweek almost looks like what I want except if I run a query like after:lastweek on a Monday it will only show my file that have been modified since Sunday at 12:00. The lastweek/lastmonth seem to relative to the start of the week/month which is not what I need.

Multi-word relative dates: week, next month, last week, past month, or coming year. The values can also be entered contracted, as follows: thisweek, nextmonth, lastweek, pastmonth, comingyear.

One nice thing about saved searches is that they are stored as an XML document and the file format is documented. I am not seeing how to form a correct value for a datetime. If I was able to understand this format, I suspect I could use a text editor and created a saved search that does what I want.

Fragment from the examples:

<conditions>
  <condition type="leafCondition" valuetype="System.StructuredQueryType.DateTime"
             property="System.DateModified" operator="imp" 
             value="R00UUUUUUUUZZXD-30NU" propertyType="wstr" />
</conditions>

To summarize I am looking for an answer to one or both of these questions

  • How do I make a query for '7 days ago' using the standard syntax?
  • How is the DateTime stored in a saved search?
share|improve this question
add comment

2 Answers

up vote 5 down vote accepted
+250

For the first part of your question: R00UUUUUUUUZZXD-30NU tells Windows to search the last 30 days. Changing 30 to 1 would make it search the last 24 hours.

In your case you are looking to set the value to R00UUUUUUUUZZXD-7NU. Reference this forum post.

For the second part of your question perhaps start by looking at the System.DateModified documentation. The other type that's mentioned, System.StructuredQueryType.DateTime, I am unable to find documentation on.

Update:

I found this gem that gets us closer to deciphering how to construct the relative DateTime values. Consider this quote:

For example, Structured Query supports relative date/time expressions, which remain unresolved until they are applied to some reference time. In a leaf node with semantic type System.StructuredQueryType.DateTime, the value can be either a VT_FILETIME or a VT_LPWSTR. VT_FILETIME is an absolute date/time so it is already resolved. VT_LPWSTR is a string representation of a relative date/time expression. The specified reference time should be a local time, but the resolved times in the resulting query expression will be in coordinated universal time (UTC).

and finally this forum posting has another example of what the DateTime is stored.

The best I can tell it is a relative date/time format. I am still unable to find any hard documentation on it.

share|improve this answer
    
+1. Nice job digging up the meaning of "R00UUUUUUUUZZXD-30NU". –  Peter Mortensen Mar 24 '10 at 22:46
add comment

Just write a script (PowerShell or Batch) that takes today's date, subtracts 7 days and executes a search based on the result. That way, you won't have to save the search, just run the script.

share|improve this answer
    
While I agree this is possible work around. This really isn't the solution I am looking for. Plus, somebody should know how the datetime value is structured. –  Zoredache Mar 15 '10 at 6:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.