Hello, I want to get a list of Document by Query.between using date.
String today = DateTime.now().toString().substring(0, 10); // YYYY-MM-DD
String oneMonthAgo = DateTime.now().subtract(Duration(days: 30)).toString().substring(0, 10);
...
dataMonth = database.listDocuments(
databaseId: databaseId,
collectionId: collectionId,
queries: [
Query.between(
'\$createdAt',
oneMonthAgo,
today),
]
...
context.log("Documents");
dataMonth.documents.every(
(element) {
context.log(element.data['data']);
return true;
},
);
// Printed 1 document, expected 3 documents
There are 3 documents with the same CreatedAt date, but only one of them is returned. Is there anything I did wrong?
Reason: different timezone, about 6 hours before the server fix: add a whole day to DateTime today
String today = DateTime.now().add(Duration(days: 1)).toString().substring(0, 10);
String oneMonthAgo = DateTime.now().subtract(Duration(days: 31)).toString().substring(0, 10);
[SOLVED] Use Query.between() to list documents by date
Recommended threads
- DeploymentStatus enum value `canceled` m...
Hey, Sorry if it has been reported already, I found an issue using the Dart SDK where the `canceled` enum value is missing from `DeploymentStatus`. This causes...
- Synchronous function execution timeout w...
I am calling server functions with xasync = true and I still get this error message. Synchronous function execution timed out. Use asynchronous execution inste...
- Flutter OAuth2 webAuth Bug?
I created with flutter an app where I can login in with my Microsoft Account. When I compile it to Web (WASM) or Android (aab) then there is no problem what so ...