question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: how to use .between() for date interval?

See original GitHub issue

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

    .where_raw("\"{}\".\"updated_at\" BETWEEN current_date - integer '7' AND current_date".format(table_a))

which is very grammar specific. is there a more db agnostic way to do this?

Happy to discuss Thanks

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
josephmancusocommented, Mar 7, 2021

@Marlysson

User.where('created_at', '<=', pendulum.now().subtract(days=7).to_datetime_string())
0reactions
josephmancusocommented, Mar 7, 2021

👍 ❤️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Write an IF Statement for Dates Between Two ... - YouTube
How do you use IF in a date range ? How do I return a value if date within range ? If date...
Read more >
SQL Between Operator overview and examples - SQLShack
This article explores the SQL Between operator to get a range of data along with its usage scenarios.
Read more >
Select data from date range between two dates - Stack Overflow
This is easy, use this query to find select data from date range between two dates select * from tabblename WHERE (datecolumn BETWEEN...
Read more >
DATE queries using BETWEEN - Ask TOM
I want to take several date/time interval values and sum them up. Do I REALLY need define my own special type using ODCIAggregateIterate()...
Read more >
Excel SUMIFS date range formula - sum if between two dates
As you can see, the difference is only in the logical operators. In the first formula, we use greater than or equal to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found