Hello, I have a question regarding Queries in Appwrite. If I have a string "YYYY-MM", how can I query the $createdAt column to match this filter?
TL;DR
The developer is querying the $createdAt column using a string in the format "YYYY-MM". The solution is to create variables for the start and end of the month using the provided date string. Then, include a query to filter records between these dates using `sdk.Query.between('$createdAt', startOfMonth, endOfMonthISO)`.const date_time = "2024-11"; const batchs = await databases.listDocuments( process.env.APPWRITE_DATABASE_ID, process.env.APPWRITE_COLLECTION_ID, [ ? ] );
[SOLVED]
TypeScript
const startOfMonth = "${date_time}-01T00:00:00.000Z";
const endOfMonth = new Date("${date_time}-01T00:00:00.000Z");
endOfMonth.setMonth(endOfMonth.getMonth() + 1);
endOfMonth.setDate(0);
const endOfMonthISO = endOfMonth.toISOString();
query.push(sdk.Query.between('$createdAt', startOfMonth, endOfMonthISO));
Recommended threads
- Relation Question
How do I create a relation from table y to an others x.$id. in my example I have a users table where I use Appwrites unique User IDs and I want other tables fo...
- Unknown attribute type: varchar / text
Since the `string` type is deprecated I tried using `varchar` and `text` in some newer tables, but when running `appwrite pull tables && appwrite types ./src/li...
- trying to figure out how to activate my...
please help