Morel
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)`. Morel
const date_time = "2024-11"; const batchs = await databases.listDocuments( process.env.APPWRITE_DATABASE_ID, process.env.APPWRITE_COLLECTION_ID, [ ? ] );
Morel
[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
- I am looking for a US/Canada developer.
- Failed creating JWT via REST
The endpoint `v1/account/jwts` aint working as REST documentation says. It only works using Cookies recived from `v1/account/sessions/email`. My test commands s...
- Adding Phone Number During User Registra...
Hi everyone I'm working on integrating user registration in my application and need to include a phone number as a mandatory field. I understand that the accou...