Search code examples
azure-cosmosdbazure-cosmosdb-tables

How to compare default Timestamp property in a cosmos DB table


The cosmos DB table entry manages a default Timestamp property for each table operation. While I am trying to query last updated entries based on the same time stamp field the result is not behaving as expected. The TableQuery looks like below:

TableQuery.GenerateFilterConditionForDate("Timestamp",
                QueryComparisons.GreaterThanOrEqual,
                timestamp)

Where timestamp is a DateTimeOffset object. I am getting 0 rows retrieved even with rows existing in the table with the Timestamp column holding a higher value. What is missing here?


Solution

  • Data in my table.

    enter image description here

    Query params.

    enter image description here

    Result.

    enter image description here

    var query = TableQuery.GenerateFilterConditionForDate("Timestamp", QueryComparisons.GreaterThanOrEqual, DateTimeOffset.Now.AddDays(-10).Date);
    var exQuery = new TableQuery<CustomerEntity>().Where(query);
    var results0 = sourcetable.ExecuteQuery(exQuery).ToList();
    //var results1 = sourcetable.ExecuteQuery(exQuery).Select(ent => (CustomerEntity)ent).ToList();