List:General Discussion« Previous MessageNext Message »
From:Andrew Braithwaite Date:November 18 2002 3:52pm
Subject:RE: mysql return days in month?
View as plain text  
Thanks for solving this all,

I have do something ugly because I only have the yyyy-mm (3rd party DB)
which ends up like this:

Mysql> select dayofmonth((concat('2004-02','-01') + interval 1 month) -
interval 1 day);

Urrggg ;)

Still, much more graceful (and more future proof) than what I just came up
with:

select case when (right('2002-04',2) = '02') then 28 when ('%09%04%06%11%'
regexp right('2002-04',2)) then 30 else 31 end as daysinmonth;

lol....

Thanks

Andrew
Sql,query

* Roger Baklund
>You can start with the first day of the _next_ month, and go 1 day back...:
>
>mysql> select dayofmonth('2002-11-01' - interval 1 day);


Thread
mysql return days in month?Andrew Braithwaite18 Nov
  • Re: mysql return days in month?Jason Burfield18 Nov
  • Re: mysql return days in month?Roger Baklund18 Nov
RE: mysql return days in month?Andrew Braithwaite18 Nov
  • Re: mysql return days in month?Pae Choi18 Nov
RE: mysql return days in month?Andrew Braithwaite18 Nov