Azure Storage Explorer Query where by Timestamp
Use TableQuery.GenerateFilterConditionForDate()
methods to set datetime based query parameters against Azure table storage tables:
using Microsoft.WindowsAzure.Storage.Table;
// Input parameters to your method, etc:
DateTimeOffset from;
DateTimeOffset until;
string DateFromFilter = TableQuery.GenerateFilterConditionForDate("Date", QueryComparisons.GreaterThanOrEqual, from);
string DateUntilFilter = TableQuery.GenerateFilterConditionForDate("Date", QueryComparisons.LessThanOrEqual, until);
finalFilter
is just a string which you build up using TableQuery methods such as CombineFilters()
:
finalFilter = TableQuery.CombineFilters(finalFilter, TableOperators.And, DateFromFilter);
finalFilter = TableQuery.CombineFilters(finalFilter, TableOperators.And, DateUntilFilter);
TableQuery<MyAzureObject> query = new TableQuery<MyAzureObject>().Where(finalFilter);
It looks like you would need to use something like below in order to filter on a Timestamp. Please look at Filtering on DateTime Properties here.
Timestamp ge datetime'2008-07-10T00:00:00Z'
This should work
Timestamp ge datetime'2013-10-06T00:00:00'
This is how you could do it:
var dateFilter = "(PartitionKey ge '0" + StartTime.Ticks + "')" + "and (PartitionKey le '0" + EndTime.Ticks + "')";
StartTime
and EndTime
will be your date range. Remember that you can only query over PartitionKey because it has index.