# Database Discussions > MySQL >  sql query for number days in a month & number of sundays in a month...

## Magesh

Hi i will give month and year...,
based on that want to find number of days in a month and number of sundays in that month...,
Its possible in sqlquery???,
If its possible plz send me the query how to find the number of days and number of sundays in a given month.....,

----------


## xart

Your first issue is to get no of days in month and you will get that by using

SELECT day(last_day('1997-10-1'));

The above query will return last day that is nothing but no of days in month.
As you told you will provide year and month but I have one more column as date that you can keep 1 as a default it wont affect your result.

Second to count no of Saturdays second part of query will give you result in Boolean form o/1 whether that day is Saturday or not.

so based upon your requirement you can count whether dd is set or not .

So combining both


SELECT day(last_day('1997-10-1')), DATE_FORMAT('1997-10-05 22:23:00', '%W') like '%Sat%'  as dd ;

----------

