MySQL Forums
Forum List  »  Knowledge Base

Re: days in a month
Posted by: Paul Svirin
Date: August 18, 2009 06:04AM

Hey, here comes your script:

SELECT CONCAT(dt.d, '-', days.d) as dates FROM (SELECT CONCAT(a1,b1) as d FROM (SELECT '0' as a1 UNION ALL SELECT '1' UNION ALL SELECT '2' UNION ALL SELECT '3') a JOIN (SELECT '0' as b1 UNION ALL SELECT '1' UNION ALL SELECT '2' UNION ALL SELECT '3' UNION ALL SELECT '4' UNION ALL SELECT '5' UNION ALL SELECT '6' UNION ALL SELECT '7' UNION ALL SELECT '8' UNION ALL SELECT '9') b WHERE CONVERT(CONCAT(a1, b1), UNSIGNED ) <= ( select DAY(CONCAT('2008-02','-01') + INTERVAL 1 MONTH - INTERVAL 1 DAY) ) AND CONCAT(a1,b1)<>'00') days JOIN (SELECT '2008-02' as d) dt ORDER BY dates;

The argument comes in format 'YYYY-MM' (here in this example there are two occurances, look for them).

hope that helps.

-----------------------
StarWind Software developer (http://www.starwindsoftware.com)

Options: ReplyQuote


Subject
Views
Written By
Posted
3474
June 17, 2009 08:31AM
3003
August 14, 2009 01:34AM
Re: days in a month
3260
August 18, 2009 06:04AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.