Get current month entries

How can I select the current month records from the MySql database table?

Like the current month is January. I would like to get the records for the month of January where the data type of my column is the timestamp table. I would like to know the SQL query.

thanks

+7
date sql mysql timestamp select
source share
3 answers

This query should work for you:

 SELECT * FROM table WHERE MONTH(columnName) = MONTH(CURRENT_DATE()) AND YEAR(columnName) = YEAR(CURRENT_DATE()) 
+29
source share

Check MySQL Datetime Functions:

Try the following:

 SELECT * FROM tableA WHERE YEAR(columnName) = YEAR(CURRENT_DATE()) AND MONTH(columnName) = MONTH(CURRENT_DATE()); 
+20
source share

Try this query:

 SELECT * FROM table WHERE MONTH(FROM_UNIXTIME(columnName))= MONTH(CURDATE()) 
0
source share

All Articles