ThisaruG
ThisaruG

Reputation: 3412

How to extract date from the DATE type in mysql?

I have a problem where I need to know which things happened before 10th day of the month. I tried this, but it doesn't give the expected result. :(

SELECT *
FROM Birth_Day
WHERE DATE(Birth_Day) < 10;

It says that it's an empty set. but there are some entries.

Upvotes: 1

Views: 55

Answers (1)

Mureinik
Mureinik

Reputation: 311526

The function you're looking for is dayofmonth (or day, which is a synonym of it):

SELECT * FROM Birth_Day WHERE DAYOFMONTH(Birth_Day) < 10; 

Upvotes: 1

Related Questions