Mysql to return the first day and last day of a number from 1-12 -


as writing stored procedure returns first day , last day of number. example , if input 2, returns 1-2-2013 , 28-2-2013, if input 7 , return 1-7-2013 , 31-7-2013. 2013 current year. can that?

thanks

to beginning of month current year (the example uses month 2):

set @themonth = 2; set @beginmonth = str_to_date(concat('1-', @themonth, '-', year(curdate())), '%d-%m-%y'); 

to calculate end of month starting beginning of month, add 1 month , subtract 1 day:

set @endmonth = @beginmonth + interval 1 month - interval 1 day; 

Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -