3

I have a table with a time field and I am trying to select between 2 timestamps which are in the format:

"2020-10-10 09:00:00.000000000"

I have tried some functions listed here but without success.

Edit: The data is there, as seen in the picture. But the example shows using 7 days ago instead of passing a timestamp.

enter image description here

David Bensoussan
  • 2,887
  • 2
  • 38
  • 55
  • 1
    Please check this page on how to ask a question on StackOverflow and improve your chances of getting an answer: https://stackoverflow.com/help/how-to-ask The query you wrote is correct and it looks like it has returned results. What problem are you facing? – MaFF Dec 21 '21 at 06:35
  • @MaFF I explained the picture – David Bensoussan Dec 21 '21 at 10:39

1 Answers1

7

You can put the key word TIMESTAMP before the string representation of the timestamp to declare a timestamp type:

SELECT TIMESTAMP '2020-10-10 09:00:00'

To filter using an interval you can use keyword BETWEEN or any comparison operator:

SELECT 
    *
FROM my_database.my_table
WHERE
    time BETWEEN TIMESTAMP '2020-10-10 09:00:00' AND TIMESTAMP '2020-10-10 11:00:00'
MaFF
  • 9,551
  • 2
  • 32
  • 41