0

there is a table with these fields

month
year
day

and these files are contain numbers like

year = 2001 and month = 10 and day = 25

and i have time stamp in php so i need to compare these in mysql

something like:

select * from times where mktime(year,month,day)<1235478554 

is there any function in mysql for this? i need to make time stamp in mysql with the mysql fields...

UPDATE 1 : i used like this and not worked

SELECT * from work_result where UNIX_TIMESTAMP('year-month-day 00:00:00')<1 

UPDATE2: enter image description here

peiman F.
  • 1,648
  • 1
  • 19
  • 42

1 Answers1

0

There's UNIX_TIMESTAMP which will get you the Unix timestamp of a given date string. Which means you need to build a date string inline in your MySQL query. Doing so is considered bad style, you should propably be storing a Unix timestamp within your database.

Robin Heller
  • 400
  • 5
  • 14
  • 1
    i used like this and not worked `SELECT * from work_result where UNIX_TIMESTAMP('year-month-day 00:00:00')<1 ` – peiman F. Dec 11 '13 at 16:02
  • Yeah, of course that won't work. You're generating the Timestamp for the year "year", the month "month" and so on. Running a *SELECT UNIX_TIMESTAMP('year-month-day 00:00:00')* will show you what I mean. – Robin Heller Dec 11 '13 at 16:05
  • 1
    i added the result image!! – peiman F. Dec 11 '13 at 16:13