<jared.pohl> schreef in bericht
news:1148558452.463381.90720j33g2000cwa.googlegro ups.com...at: [url]http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html[/url]> Hey all.
>
> I just started usng mysql, and need a bit of help arriving at the
> following
>
> select date, datefunctionhere
> from table;
>
> DATE | DATE_ADD_FUNCTION_HERE
> 28/02/2006 | 31/03/2006
> 31/03/2006 | 30/04/2006
> 30/04/2006 | 31/05/2006
>
> As you can see from the above pretend sql and result-set, i basically
> want to arrive (using the date functions) at the end of the month of
> the following month given a current date. The problem is when you use
> the date_add() function on 28 february you will only get to the 28th of
> march instead of 31st of march etc.
>
> sorry if this doesnt make sense, but any help would be appreciated.
>
> cheers guys
>
> Jared
>
if find:
a.. LAST_DAY(date)
Takes a date or datetime value and returns the corresponding value for the
last day of the month. Returns NULL if the argument is invalid.
mysql> SELECT LAST_DAY('2003-02-05');
-> '2003-02-28'
mysql> SELECT LAST_DAY('2004-02-05');
-> '2004-02-29'
mysql> SELECT LAST_DAY('2004-01-01 01:01:01');
-> '2004-01-31'
mysql> SELECT LAST_DAY('2003-03-32');
-> NULL
a..
Bookmarks