Search code examples
sqlapache-phoenix

date queries in phoenix sql?


How do you select observations recorded in between now and 3 hrs ago i.e. now-3? There is a column which has timestamp and I am referring to that column in this question. I know phoenix has function current_time() which can give us the current time but how can I subtract 3 hrs from it?

select col1, col2, col3 
from table 
where col1 between current_time() and ???;

What should I use at ??? ?


Solution

  • Phoenix does not support interval data types. https://phoenix.apache.org/language/datatypes.html

    You should subtract a number which either represents a number of days (use fractional days) or milliseconds. I don't remember which it was though.