locked
filter based on nillable datetime field RRS feed

  • Question

  • Hi,

    I'm trying to retrieve entities whose timestamp is later than a specific date, however, I get the following error message:

    Operator 'gt' incompatible with operand types 'System.Nullable`1[[System.DateTime, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]' and 'System.String' at position 10.

    Help appreciated!
    Mats
    matek994
    Thursday, March 11, 2010 9:42 PM

Answers

  • To specify a datetime constant as part of the filter criteria, you need to prefix the datetime string with "datetime". For example:

    $filter=DiscontinuedDate gt datetime'2000-01-01'

    Hope this helps.


    Regards,
    PQ
    Peter Q. http://blogs.msdn.com/peter_qian
    Friday, March 12, 2010 9:08 AM
    Answerer

All replies

  • Hi,

    Could you please send us the query you're trying to make (the URL should be sufficient) and some description of the data model. Ideally the $metadata output (or part of it which relates to the query).
    Also if you're getting an exception could you please send us the callstack of that exception?

    Thanks,


    Vitek Karas [MSFT]
    Thursday, March 11, 2010 10:51 PM
    Moderator
  • To specify a datetime constant as part of the filter criteria, you need to prefix the datetime string with "datetime". For example:

    $filter=DiscontinuedDate gt datetime'2000-01-01'

    Hope this helps.


    Regards,
    PQ
    Peter Q. http://blogs.msdn.com/peter_qian
    Friday, March 12, 2010 9:08 AM
    Answerer
  • The prefixing fixed it! Don't think I saw anything of that in the online documentation! Thanks for prompt reply!
    matek994
    Friday, March 12, 2010 10:30 AM
  • Hi,

    Samples for each data type are here: http://msdn.microsoft.com/en-us/library/cc907912.aspx

    Thanks,
    Vitek Karas [MSFT]
    Friday, March 12, 2010 2:30 PM
    Moderator