Community Queries - Date Ranges

Vote:
 

I'm trying to create a query of Entry by date range on the PublicationStart property of the class.

I can't work out how you add the range, I can't find any examples, does anyone have any?

I've done the usual:

EntryQuery entry = new EntryQuery();
entry.PublicationStart = new DateTimeCriterion();

I was looking at entry.PublicationStart.Operator as this is a RangeCriterion(), but I can't really work out how to use it...... 

On a separate note, are there any good resources of examples/docs of how to use the Query system?  The Community SDK is good for really basic examples but lacks the more complex stuff that is most likely to arise when implementing in real situations.

 

 

#37316
Mar 02, 2010 18:46
Vote:
 

 

 

 

 

 

 

entryQuery.PublicationStart = new DateTimeCriterion();

entryQuery.PublicationStart.Operator = ComparisonOperator.GreaterThan | ComparisonOperator.Equals;
entryQuery.PublicationStart.Value = myRangeStart;
entryQuery.PublicationStart.Operator2 = ComparisonOperator.LessThan | ComparisonOperator.Equals;
entryQuery.PublicationStart.Value2 = myRangeEnd;

 

I believe that something like this would do what you're asking for:

entryQuery.PublicationStart = new DateTimeCriterion();
entryQuery.PublicationStart.Operator = ComparisonOperator.GreaterThan | ComparisonOperator.Equals;
entryQuery.PublicationStart.Value = myRangeStart;
entryQuery.PublicationStart.Operator2 = ComparisonOperator.LessThan | ComparisonOperator.Equals;
entryQuery.PublicationStart.Value2 = myRangeEnd;

 

(If you don't want the interval to be inclusive you can just remove the bitwise OR with Equals)

 

/Håkan

#37406
Mar 04, 2010 17:08
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.