I have a table with a few records and for each of these records I've also added a UNIX_TIMESTAMP. Now, I also have a search engine for those records in which I can choose a date using a jQuery datapicker. My question is how do I make the request so that to select all timestamps from the database for a certain date.
Asked
Active
Viewed 48 times
0
-
`SELECT column(s) FROM table WHERE date='?'` – Funk Forty Niner Sep 30 '14 at 19:57
-
You read a few SQL tutorials, and then try to get it to work by trial and error. Or that was how we learnt stuff back in the olden days, at least. – Sverri M. Olsen Sep 30 '14 at 20:20
3 Answers
2
With an index on your timestamp column you will get a faster result with:
SELECT *
FROM table_name
WHERE time_stamp_column_name >= :date_picked
AND time_stamp_column_name < :date_picked + INTERVAL 1 DAY
Where :date_picked
is your bound-in picked date as a string in the format 'YYYY-MM-DD'
.

Arth
- 12,789
- 5
- 37
- 69
1
You can use from_unixtime
to convert it into a date
select *
from
table
where
date(from_unixtime(your_timestamp_col)) = '2014-10-01'

M Khalid Junaid
- 63,861
- 10
- 90
- 118