Back

[SOLVED] Problems Querying $updatedAt

  • 0
  • Databases
Tanner Meade
12 Mar, 2023, 06:35

I'm having some trouble querying the $updatedAt attribute. I'm using Query.greaterThan("\$updatedAt", lastSyncDate) to generate the query string greaterThan("$updatedAt", [2023-03-11 23:22:16.190051]) where the coding language is dart and lastSyncDate is a DateTime object. Yet the returned results have an $updatedAt of before that date on 2023-02-18. I've tried making sure there is a proper index for this and the mentioned query is the only query being used.

TL;DR
Summary: User is having trouble querying the $updatedAt attribute. The returned results have an $updatedAt date before the provided query date. User mentions the issue is not related to daylight savings time. User confirms that the database and collection ids are correct. Solution: Another user suggests converting the lastSyncDate to UTC format using the toUtc() and toIso8601String() methods. User confirms that this solution works.
Tanner Meade
12 Mar, 2023, 06:36

The database and collection ids are correct. This is a real head scratcher.

Tanner Meade
12 Mar, 2023, 06:42

Here in the US we have a weird thing called day light savings where the clocks get set forward an hour tonight at 2am, but neither the server nor where the client is at should be affected by that right now. And even if it was, it shouldn't affect it by thinking a 3 week old date is in the future.

Drake
12 Mar, 2023, 16:09

Can you try to convert the datetime a bit more? Like:

TypeScript
lastSyncDate.toUtc().toIso8601String()
Tanner Meade
15 Mar, 2023, 05:06

Works. Thanks!

Tanner Meade
15 Mar, 2023, 05:06

[SOLVED] Problems Querying $updatedAt

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more