Friday, May 8, 2009

MOSS Search DateTime comparation

Using the MOSS search one of the criteria was to match some items to a DateTime criteria. I have to specify that I was using FullTextSqlQuery and I had to build the query into the code because some other custom property ware added as criteria for search.

Now back to DateTime, all seems to work for dates greater (>) and less (<). My problem was matching on equal criteria. According to MSDN we must not use equal criteria because the way the date is stored into database. They stored with hour, minute, seconds, milliseconds etc. They say that using “=” you will get unpredictable search results.

But since the client want this and we have to make the client happy I had to find a solution to this. Only way to solve the problem was instead of writing

TimeStart = '2009-04-23'

to write

( TimeStart >= '2009-04-22' ) AND (TimeStart < '2009-04-23' )

as matching criteria.

It seems to work in my case.

No comments:

Post a Comment