8000 🚀 Feature: Add feature for getting data between specific date and time? · Issue #6340 · appwrite/appwrite · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

🚀 Feature: Add feature for getting data between specific date and time? #6340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
SMARTMICROWORLD opened this issue Sep 27, 2023 · 4 comments
Closed
2 tasks done
Assignees
Labels
product / databases Fixes and upgrades for the Appwrite Database.

Comments

@SMARTMICROWORLD
Copy link

🔖 Feature description

I was trying to fetch data between time like this:
Query.greaterThanEqual('date_time', specifiDate), Query.lessThanEqual('date_time', new Date()),
but getting error like:
Error: [AppwriteException: Server Error]
Please add this feature as fast as possible please.

🎤 Pitch

Firebase offers this feature like:
.where('date_time', '>=', specifiDate) .where('date_time', '<=', new Date())

It will be very useful for users to find any items or posts between or before/after an specific time
Thanks

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@xuelink
Copy link
Contributor
xuelink commented Sep 27, 2023

There is a query method named between due to docs. However, it accepts only number or string. That is why there is an opened issue to add feature floatand datetime to Query.between method.

Screenshot 2023-09-27 at 19 45 46

Related issue: #5650
Related comment : #5650 (comment)

I could not use betweenmethod for the same query with datetime so i solve my problem like that

    const queries: any[] = [];

 
8000
   // Query for users with birthdates between the selected min and max ages
    if (filterData?.minAge && filterData?.maxAge) {
      const minDate = new Date();
      minDate.setFullYear(minDate.getFullYear() - filterData?.maxAge);
      const maxDate = new Date();
      maxDate.setFullYear(maxDate.getFullYear() - filterData?.minAge);

      queries.push(Query.greaterThanEqual('birthdate', minDate.toISOString()));
      queries.push(Query.lessThanEqual('birthdate', maxDate.toISOString()));
    }

...

    this.appwrite.listDocuments(
      environment.appwrite.USERS_COLLECTION,
      queries
    );

@stnguyen90 stnguyen90 added the product / databases Fixes and upgrades for the Appwrite Database. label Sep 27, 2023
@stnguyen90 stnguyen90 self-assigned this Sep 27, 2023
@SMARTMICROWORLD
Copy link
Author

There is a query method named between due to docs. However, it accepts only number or string. That is why there is an opened issue to add feature floatand datetime to Query.between method.

Screenshot 2023-09-27 at 19 45 46 Related issue: #5650 Related comment : [#5650 (comment)](https://github.com//issues/5650#issuecomment-1736915331)

I could not use betweenmethod for the same query with datetime so i solve my problem like that

    const queries: any[] = [];

    // Query for users with birthdates between the selected min and max ages
    if (filterData?.minAge && filterData?.maxAge) {
      const minDate = new Date();
      minDate.setFullYear(minDate.getFullYear() - filterData?.maxAge);
      const maxDate = new Date();
      maxDate.setFullYear(maxDate.getFullYear() - filterData?.minAge);

      queries.push(Query.greaterThanEqual('birthdate', minDate.toISOString()));
      queries.push(Query.lessThanEqual('birthdate', maxDate.toISOString()));
    }

...

    this.appwrite.listDocuments(
      environment.appwrite.USERS_COLLECTION,
      queries
    );

What if I want to fetch posts between 1 week, 1 month or a year?
Beacuse I have leader board screen where I am counting each user's posts between a week, months or a year, based on numbers I am ranking them.

@stnguyen90
Copy link
Contributor

@SMARTMICROWORLD, dates are ISO 8601 formatted strings in UTC timezone (like 2011-10-05T14:48:00.000Z). You can build a greater than and less than query that filters for any range you want.

@rakesh-venkata
Copy link

Hey,Is this issue still open.I like to work on it.

@stnguyen90 stnguyen90 closed this as not planned Won't fix, can't repro, duplicate, stale Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product / databases Fixes and upgrades for the Appwrite Database.
Projects
None yet
Development

No branches or pull requests

4 participants
0