Passing null date values to QueryByAttribute

Sep 14, 2012 at 4:06 PM
Edited Sep 14, 2012 at 4:07 PM

I need to return records where one of the record's datetime attribute's value is null. However, QueryByAttribute does not return the correct results. If I pass null as the value, an exception is generated. If I pass "" or "null" or "NaN" as the value, no results are returned (because the attribute does not equal "" or "null" or "NaN").

I also have a filtered view that uses the same parameters. Looking at the FetchXML for the view, I noticed that the value is not passed at all for a null datetime attribute; instead the operator is set to null.

<condition attribute="new_enddate" operator="null" />

So how do I send null datetime values (operators) to the function?




Sep 17, 2012 at 8:12 AM


By definition, QueryByAttribute

Retrieves instances of a specific entity type by specifying a set of attribute and value pairs. 

It only works for 'equal' parameter. I think you will need to use Fetch method to pass null value.

Hope this helps.