We’ll calculate the last day of the month using two functions: DATEADD and DAY. The example date … In the code snippets below, I will show you how to get the last date of this month, as well as the last day of a month from a specified date. Note: You can just make a single file out of it to achieve your wanted output Use mysql_real_escape_string() to sanitize the passed-on value to prevent SQL injections You should use mysqli_* instead of the deprecated mysql_* API Form them in a single file like this (display.php):