Reputation: 49
I have a problem with a query. I receive NULL
as a result:
SELECT * FROM `table1`
WHERE `date` BETWEEN UNIX_TIMESTAMP(1438387200) AND UNIX_TIMESTAMP(1440979200)
I have tried several commands what I find here, but every command give me
the same : NULL
as a result, but without any errors.
Is someone know command that is working properly ?
Upvotes: 1
Views: 202
Reputation: 49
you can try like this one :
SELECT * FROM `table1` WHERE DATE_FORMAT(FROM_UNIXTIME(`date`), '%d-%m-%Y') BETWEEN DATE_FORMAT(FROM_UNIXTIME(1438387200), '%d-%m-%Y') AND DATE_FORMAT(FROM_UNIXTIME(1440979200), '%d-%m-%Y')
Upvotes: 0
Reputation:
UNIX_TIMESTAMP in MySQL converts from a normal datetime string into UNIX time. The function you probably want is FROM_UNIXTIME.
Upvotes: 1