Get records of current month

178,297

Solution 1

This query should work for you:

SELECT *
FROM table
WHERE MONTH(columnName) = MONTH(CURRENT_DATE())
AND YEAR(columnName) = YEAR(CURRENT_DATE())

Solution 2

Check the MySQL Datetime Functions:

Try this:

SELECT * 
FROM tableA 
WHERE YEAR(columnName) = YEAR(CURRENT_DATE()) AND 
      MONTH(columnName) = MONTH(CURRENT_DATE());

Solution 3

Try this query:

SELECT *
FROM table 
WHERE MONTH(FROM_UNIXTIME(columnName))= MONTH(CURDATE())
Share:
178,297
Foysal Vai
Author by

Foysal Vai

Updated on October 05, 2020

Comments

  • Foysal Vai
    Foysal Vai over 3 years

    How can I select Current Month records from a table of MySql database??

    Like now current month is January. I would like to get records of January Month, Where data type of my table column is timestamp.I would like to know the sql query.

    Thanks