
How to make query to fetch only todays data in appwrite cloud version

you can use greater than and pass an iso formatted string in UTC timezone as the value

thanks

[SOLVED] How to make query to fetch only todays data in appwrite cloud version

trying to fetch todays data but its not working as aspected
final todayStart = DateTime.utc(now.year, now.month, now.day);
//print( todayStart.toIso8601String());
// Fetch the initial batch of transactions
final res = await db.listDocuments(
databaseId: '5439e7ae4abb114f2b1',
collectionId: '843ee466b451ce50ad7',
queries: [
Query.offset(0), // Start with an offset of 0
Query.orderDesc("\$createdAt"),
Query.greaterThan("\$createdAt", todayStart.toIso8601String()),
],
);```

what exactly is "not as expected"?

its showing yesterdays data also

how about if you conver those to UTC? is it still yesterday?

yes its showing yesterdays and todays mix data , tried without converting UTC but its not fetching any data from server

would you please share the raw string value of the oldest document in the response?

{code: [8904275300006, 8901030875212], productName: [Hallelujah , yeshu teri hamad kara ], sellingPrice: [12, 12], quantity: [4, 4], totalQuantity: [], productUnit: [Piece, Piece], date: 2023-06-02T18:03:35.026+00:00, paymentMode: Cash, $id: 6479e19fb2fb54da205f, $createdAt: 2023-06-02T12:33:35.733+00:00, $updatedAt: 2023-06-02T12:33:35.733+00:00, $permissions: [read("user:647387d4e0aab0d237ae"), update("user:647387d4e0aab0d237ae"), delete("user:647387d4e0aab0d237ae")], $collectionId: 643ee466b6cf1ce50ad7, $databaseId: 6439e7ae4abb3e14f2b1}

2023-06-02T12:33:35.733+00:00
that looks like current day 🧐

i don't think this conversion is right

ok, btw today is 2023-06-03 for me

try this:
final now = DateTime.now();
final today = DateTime(now.year, now.month, now.day);
//print( todayStart.toIso8601String());
// Fetch the initial batch of transactions
final res = await db.listDocuments(
databaseId: '5439e7ae4abb114f2b1',
collectionId: '843ee466b451ce50ad7',
queries: [
Query.offset(0), // Start with an offset of 0
Query.orderDesc("\$createdAt"),
Query.greaterThan("\$createdAt", today.toUtc().toIso8601String()),
],
);
Recommended threads
- Error response from daemon: driver faile...
on endpoint appwrite-traefik (00bbc10e5875d0c367d8975c6abc946a77b7ec201a64a825399add44fb34ebb4): failed to bind port 0.0.0.0:80/tcp: Error starting userland pro...
- "Memberships privacy" setting in 1.7.4
Hi everyone, I'm experiencing an issue with a clean self-hosted installation of Appwrite version 1.7.4. I previously used version 1.6.1, and if I remember corre...
- Issue with Appwrite Function Execution –...
Hi all, I'm encountering an issue when calling an Appwrite function from my Flutter app. **Environment:** ```Flutter SDK: 3.27.3 Appwrite Flutter SDK: 16.1.0```...
