Results 1 to 2 of 2

Thread: sql query for number days in a month & number of sundays in a month...

  1. #1
    Join Date
    Apr 2007
    Posts
    1

    sql query for number days in a month & number of sundays in a month...

    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.....,

  2. #2
    Join Date
    Apr 2007
    Posts
    6

    sql query

    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 ;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •