Support timestamp and time functions on SQL fliters
See original GitHub issueHad a conversation today with a user who wanted to be able to apply a filter like the following:
SELECT * WHERE time < NOW() - "5 minutes"
It would be handy to have a timestamp type and a handful of time-related functions. Off the top of my head:
- NOW()
- ADD / SUBTRACT
- MINUTE / HOUR / DAY / DAY_OF_WEEK / MONTH / YEAR
- LESS-THAN / GREATER-THAN
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
How to filter timstamps in sql. - Forum - SolarWinds THWACK
I opened the database and I need to filter the dates that alerts have been triggerd. I thought it would have been similar...
Read more >HOW TO: Use DATE or TIMESTAMP columns to filter data in ...
To filter query results using 'DATE/TIMESTAMP columns' present in tables of IDV, comparison operators (= < > <= ), BETWEEN and IN operators...
Read more >Working with timestamp values in select statements to filter ...
Answer. Proper casting and or standard SQL date/time functions can be used to help filter on date and time when there is a...
Read more >Filter/WHERE using timestamp - sql - Stack Overflow
Use DATEPART function. WHERE DATEPART(hh, [Date Column]) between 7 and 17. or. WHERE NOT DATEPART(hh, [Date Column]) between 7 and 17.
Read more >DATE/TIME Functions in SQL. Tutorial on how to use CAST ...
Working with dates and times is a common practice when working in SQL. Using dates, we can calculate changes over time, trends in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’d probably lean towards whatever is in the SQL-99 standard (or later equivalent); I picked those out of a SQL manpage, but this book seems to be freely available and cover the standard itself.
INTERVAL '5' MINUTE
is an interesting syntax. Seems like a reason thing to do. Someone want to submit a PR?