retrieve multiple and dates RRS feed

  • Question

  • Hi Everyone, I am having problems with a retrievemultiple with a datetime as a condition.  I can't get it to return any reults at all. I think it's something to do with the way the date is formatted, but for the life of me i can't see why it's not working, does anyone have any idea's?

    I am querying against a new attribute named new_datenquired.  it is of type datetime, date only and i would like to start with just returning any value with a date less than today..... There is only 6 records and they all have a date less than today

    My code is:


    Sub Main()


    Dim token As New CrmAuthenticationToken


    Dim service As New CrmService()

    token.AuthenticationType = 0

    token.OrganizationName =


    service.Url =


    service.CrmAuthenticationTokenValue = token

    service.Credentials = System.Net.CredentialCache.DefaultCredentials


    Dim SearchDate As CrmDateTime = New CrmDateTime()

    SearchDate.Value = DateTime.Now.ToString(



    Dim cols As ColumnSet = New ColumnSet()


    Dim colNames() As String = {"New_dateenquired", "subject", "fullname", "leadid"}

    cols.Attributes = colNames


    Dim query As QueryExpression = New QueryExpression()

    query.PageInfo =

    New PagingInfo()

    query.PageInfo.Count = 25

    query.PageInfo.PageNumber = 1

    query.EntityName = EntityName.lead.ToString()

    query.ColumnSet = cols


    Dim condition As ConditionExpression = New ConditionExpression()

    condition.AttributeName =


    condition.Operator = ConditionOperator.LessEqual

    condition.Values =

    New String() {SearchDate.Value}


    Dim filter As FilterExpression = New FilterExpression()

    filter.FilterOperator = LogicalOperator.And

    filter.Conditions =

    New ConditionExpression() {condition}

    query.Criteria = filter


    Dim leads As BusinessEntityCollection = service.RetrieveMultiple(query)


    For Each currentlead As lead In leads.BusinessEntities

    Console.WriteLine(currentlead.leadid.Value.ToString() +

    " " + currentlead.subject + " " + currentlead.fullname)





    End Sub

    Monday, October 12, 2009 11:24 AM


All replies