MySQL - Last Day Of Quarter (Most Efficient Way)

Viewed 6132

I've seen a few other examples of this for SQL, but I am looking particularly for MySQL.

This is the code I have (which works, but I think it's drastically inefficient). I am using the arbitrary date '2011-05-15' which should and does return '2011-06-30'.

DATE_SUB( 
    DATE_ADD( 
        CONCAT( 
            YEAR( CURDATE() ), 
            '-01-01' 
        ), 
        INTERVAL QUARTER('2011-05-15') QUARTER 
    ), 
    INTERVAL 1 DAY
)

What is the better way to do this?

1 Answers
Related