Trying to get those documents whose modified date(datetime) is equal to (currentdate -7) but NOT working, pseudocode as below
"SELECT * FROM c where c.LastModifiedDate = (GetCurrentDate-7)"
How to do it using cosmosdb sql api? without udf because we have timer trigger based Azure function which querying Cosmos DB using above SQL query directly when it get triggered each time and binding results to a parameter of the function.
[FunctionName("TimerCosmosDbWriteExample")]
public static async Task Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer,
TraceWriter log,
[CosmosDB(
databaseName: "Database",
collectionName: "Collection",
ConnectionStringSetting = "MyConnectionString",
SqlQuery = "SELECT * FROM c where c.LastModifiedDate = GetCurrentDate-7")] IEnumerable<Entity> documents)
{
//function body -- loop through retrieved documents & process it
}
[DocumentDb]
parameter attribute vs just initializing the Cosmos Client in the function and executing that same code? That way you can at least manipulate the date and parameters. I sadly don't know an easier way to do it. – Mark C.