Wednesday, January 08, 2014

Select current ( day ,month , year ) records mysql from timestamp column

Get Todays Record From table

SELECT * 
  FROM table1
  WHERE DAY(FROM_UNIXTIME(timestampfield)) = DAY(CURDATE())
 
Get Current Month Records
 
SELECT * 
  FROM table1  WHERE MONTH(FROM_UNIXTIME(timestampfield)) = MONTH(CURDATE()) 

Get current year Records
 
SELECT * 
  FROM table1  WHERE YEAR(FROM_UNIXTIME(timestampfield)) = YEAR(CURDATE())  
 
Just change the table name and timestampfield name .....

1 comment: