I've got an Azure Function with a Cosmos DB binding. What I want to do is to get all the documents with a date in the future.
Something like this would work...
SqlQuery = "SELECT * FROM c WHERE c.Filter = {FilterTerm} AND c.SomeDate < '" + DateTime.UtcNow + "'")]
Except that the fact that the binding live in an attribute means they have to be a constant expression.
As far as I can tell, there aren't any functions built into Cosmos DB (like, for instance, GetDate()
in T-SQL).
So currently I'm querying the lot and doing the date filtering in memory. This works, but it means a lot more DB traffic than I'd like.
Is there any way to do this more effectively?
the binding live in an attribute means they have to be a constant expression
. Per my understanding, you want to implement GetDate() function in cosmos db query sql, right? So that you could filter the data on the server side. – Jay Gong