gple Posted October 3, 2008 Share Posted October 3, 2008 How do i use today's date to find all records in an SQL statement that are all within one year of todays date. $date="2007-10-31"; $tday=date("Y-m-d"); how do i run a query to check if $date is less than one year of $tday. Link to comment https://forums.phpfreaks.com/topic/126903-solved-sql-statement/ Share on other sites More sharing options...
awpti Posted October 3, 2008 Share Posted October 3, 2008 <?php $today = date('Y-m-d'); $last_year = date('Y-m-d', strtotime('last year')); // The above is very rough, you shouldn't actually use strtotime $res = mysql_query("SELECT * FROM some_table WHERE my_date_field BETWEEN '{$today}' AND '{$last_year}'"); Link to comment https://forums.phpfreaks.com/topic/126903-solved-sql-statement/#findComment-656389 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.