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 Link to comment https://forums.phpfreaks.com/topic/120470-solved-mysql-date-question/ 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 Link to comment https://forums.phpfreaks.com/topic/120470-solved-mysql-date-question/#findComment-620755 Share on other sites More sharing options...
djbuddhi Posted August 20, 2008 Author Share Posted August 20, 2008 yes php 4.3.3 Link to comment https://forums.phpfreaks.com/topic/120470-solved-mysql-date-question/#findComment-620771 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. Link to comment https://forums.phpfreaks.com/topic/120470-solved-mysql-date-question/#findComment-620779 Share on other sites More sharing options...
djbuddhi Posted August 20, 2008 Author Share Posted August 20, 2008 thanks pal Link to comment https://forums.phpfreaks.com/topic/120470-solved-mysql-date-question/#findComment-620796 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 Link to comment https://forums.phpfreaks.com/topic/120470-solved-mysql-date-question/#findComment-620807 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 : Link to comment https://forums.phpfreaks.com/topic/120470-solved-mysql-date-question/#findComment-620840 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 Link to comment https://forums.phpfreaks.com/topic/120470-solved-mysql-date-question/#findComment-620867 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 Link to comment https://forums.phpfreaks.com/topic/120470-solved-mysql-date-question/#findComment-620874 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"; ?> Link to comment https://forums.phpfreaks.com/topic/120470-solved-mysql-date-question/#findComment-621668 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.