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
Question: how to use .between() for date interval? #407
Comments
Can't you just use the between and pass 2 dates? Masonite ORM installs with pendulum so it would look something like: Invoice.between('created_at', pendulum.now().subtract(days=7).to_datetime_string(), pendulum.now().to_datetime_string()) |
@josephmancuso There some method to simulate dates greater or lower than some point? |
@Marlysson what do you mean? for pendulum? |
No, in database level. Like this https://docs.djangoproject.com/en/3.1/ref/models/querysets/#year |
User.where('created_at', '<=', pendulum.now().subtract(days=7).to_datetime_string()) |
Let me clarify Consider this scenario: Another server runs the webserver is the US for example. Won't generating a pendulum date on the webserver be transformed into an incorrect date when sent to the database? I'm concerned as I'm starting work with AWS services and the RDS could be in any timezone and the lambdas could be in any other timezone. Am I overthinking this? |
I think so? date standardization is even more a PITA when you're trying to understand someone else PITA problem 😆 If all dates are in UTC then there should be no issues right? If the db engine in Sydney has dates stored as UTC then it doesn't matter which dates you check against as long as all dates are in UTC you are checking against. Its been a long day and I'm tired so my brain is shot as well .. In other words, if you make sure all dates are in the same timezone (UTC) across the board then I think you should be good |
Thanks for the reply. Get some rest and keep up the great work |
👍 ❤️ |
This is a general "how to" question
I was looking to use .between() for a date interval eg low: today - 7 days, high: date today.
Currently I'm using postgres so the where_raw looks like this
which is very grammar specific.
is there a more db agnostic way to do this?
Happy to discuss
Thanks
The text was updated successfully, but these errors were encountered: