0

I have a problem in fetching data from database, my date fromat is 1438697362 this value comes in result of this php default function time();

I am confused how can I fetch the data with this time and date format.

select * from table_name 
where  created_date 
BETWEEN '1438697362' AND '1440843077'

can anyone please help me in this matter.

Funk Forty Niner
  • 74,450
  • 15
  • 68
  • 141

3 Answers3

1
select * from table_name where created_date BETWEEN FROM_UNIXTIME(1438697362) AND FROM_UNIXTIME(1440843077)

or

select * from table_name where UNIX_TIMESTAMP(created_date) BETWEEN 1438697362 AND 1440843077
mario.van.zadel
  • 2,919
  • 14
  • 23
0

You can do like this:

SELECT * FROM table_name WHERE created_date > 1438697362 AND created_date < 1440843077

This will select between the 2 date ranges

JPJens
  • 1,185
  • 1
  • 17
  • 39
0

See this answer:
Convert Unix timestamp into human readable date using MySQL

Which says:

SELECT
  from_unixtime(timestamp) 
FROM 
  your_table    

answer by Parkyprg

or put another way:

SELECT other fields here, FROM_UNIXTIME(date_ordered)
FROM orders
WHERE ...
Community
  • 1
  • 1
Rolf of Saxony
  • 21,661
  • 5
  • 39
  • 60