This project is read-only.

Search with Dates?

Feb 22, 2009 at 8:04 PM
Hi there,

Just wondering if there is a way to do a range search with dates?  I tried the RangeQueryParameter class, but it seems to accept only numbers.  I added this constructor, seems to work:

public RangeQueryParameter( string field, DateTime startDate, DateTime endDate )
            : this( field, startDate.ToString( "s" ) + "Z", endDate.ToString( "s" ) + "Z" )
{            
}

If I'm missing something, please let me know

Thanks!
Brian.
Feb 23, 2009 at 4:49 AM
On Sun, Feb 22, 2009 at 2:04 PM, [email removed] wrote:
> From: brian519
>
> Hi there,
>
> Just wondering if there is a way to do a range search with dates? I tried
> the RangeQueryParameter class, but it seems to accept only numbers. I added
> this constructor, seems to work:
>
> public RangeQueryParameter( string field, DateTime startDate, DateTime
> endDate )
> : this( field, startDate.ToString( "s" ) + "Z",
> endDate.ToString( "s" ) + "Z" )
> {
> }
>
> If I'm missing something, please let me know

I am pretty sure there is nothing in code that explicitly allows you
to Date range queries. You could build [date1 TO date2] string
yourself and call AddField on QueryBuilder, but what you have is
better, I think, and could be added to the library.

The only thing I would say is that you could make the startDat and
endDate nullable so that we can do searches like [datehere TO *] (e.g.
give me articles that have pubdate 12/01/2008 or newer)



>
> Thanks!
> Brian.
>
> Read the full discussion online.
>
> To add a post to this discussion, reply to this email
> ([email removed])
>
> To start a new discussion for this project, email
> [email removed]
>
> You are receiving this email because you subscribed to this discussion on
> CodePlex. You can unsubscribe or change your settings on codePlex.com.
>
> Please note: Images and attachments will be removed from emails. Any posts
> to this discussion will also be available online at codeplex.com
Feb 23, 2009 at 7:00 PM
you mean like:

DateTime? startDate, DateTime? endDate

ya, that's pretty good.  what I'm doing is passing in DateTime.MinValue for the start or DateTime.MaxValue for the end if it's open ended, but your way is better

Brian.