Reputation: 1
I have this query:
SELECT *
FROM abc
WHERE filehash IN (
SELECT xyz
FROM 123
WHERE FROM_UNIXTIME(timecreated,'%m-%d-%Y') >= "01-01-2000")
But I need a time range: >= "01-01-2000" AND <= "01-02-2000"
I tried e few things, but nothing worked. Any help for a query is appreciated.
Upvotes: 0
Views: 109
Reputation: 272416
Instead of converting the unix timestamp to string for comparison, convert the two input strings to unix timestamp and compare:
SELECT *
FROM abc
WHERE filehash IN (
SELECT xyz
FROM 123
WHERE timecreated >= UNIX_TIMESTAMP('2000-01-01')
AND timecreated <= UNIX_TIMESTAMP('2000-01-02')
)
See UNIX_TIMESTAMP
documentation for details about how the string should be formatted.
Upvotes: 1