djbuddhi Posted August 20, 2008 Share Posted August 20, 2008 Guys; How 2 get the last date of the current month in mysql Exp if the system month is February return should be 29 like that ,how to get it ? need help... :o Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted August 20, 2008 Share Posted August 20, 2008 are u using it with php at all? because php can do it a lot easier Quote Link to comment Share on other sites More sharing options...
djbuddhi Posted August 20, 2008 Author Share Posted August 20, 2008 yes php 4.3.3 Quote Link to comment Share on other sites More sharing options...
akitchin Posted August 20, 2008 Share Posted August 20, 2008 i see no reason why MySQL can't be used for this: http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_last-day that does exactly what you need, and most likely in an easier fashion than php. Quote Link to comment Share on other sites More sharing options...
djbuddhi Posted August 20, 2008 Author Share Posted August 20, 2008 thanks pal Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted August 20, 2008 Share Posted August 20, 2008 well now that is a handy tip I was gonna say use mktime in php and then just make it this month +1 and the day be -1 to get what u wanted. What a directly obvious mysql answer Quote Link to comment Share on other sites More sharing options...
djbuddhi Posted August 20, 2008 Author Share Posted August 20, 2008 hey cooldude832 can u post the code ,i am not familiar with the mKtime this thing : Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted August 20, 2008 Share Posted August 20, 2008 <?php $last_day = date("Y-m-d",mktime(0,0,0,date("m")+1,-1,date("Y")); ?> http://us.php.net/mktime should return 2008-08-31 if ran in august Quote Link to comment Share on other sites More sharing options...
djbuddhi Posted August 20, 2008 Author Share Posted August 20, 2008 thanks 4 the support buddy ;D have a good day TC Quote Link to comment Share on other sites More sharing options...
djbuddhi Posted August 21, 2008 Author Share Posted August 21, 2008 i have a good method and it works <?php $num = cal_days_in_month(CAL_GREGORIAN, 2, 2008) ; echo "There were $num days in May 2008"; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.