Home > Software engineering >  sqlQuery where timestamp is a specific date
sqlQuery where timestamp is a specific date

Time:02-21

Hy guys I have this table: VisitedCity

id timestamp name city
1 2022-02-02 10:02:23 Mark LA
2 2022-01-15 08:45:01 Phil NY
3 2022-02-05 11:09:45 John MI

My query :

SELECT * FROM VisitedCity
WHERE timestamp = '2022-02-02'

But it doesn't return any rows. How Could I do it?

CodePudding user response:

You can't use = if you don't want an exact match. You need to query for an interval:

SELECT *
FROM VisitedCity
WHERE timestamp >= '2022-02-02 00:00:00' AND timestamp < '2022-02-03 00:00:00'
  • Related