guyfromfl Posted August 4, 2007 Share Posted August 4, 2007 how would you delete a transaction from 3 years ago? $sql = "DELETE FROM tbl_transactions WHERE transDate < '$today <<- 3 years>> '" OR DIE (mysql_error()); im pretty new to sql and appriciate the help Link to comment https://forums.phpfreaks.com/topic/63346-sql-date-function/ Share on other sites More sharing options...
BlueSkyIS Posted August 4, 2007 Share Posted August 4, 2007 One way: $sql = "DELETE FROM tbl_transactions WHERE DATEDIFF(transDate,NOW()) > 1095; 3 x 365 = 1095. This doesn't account for leap year. -BSIS Link to comment https://forums.phpfreaks.com/topic/63346-sql-date-function/#findComment-315722 Share on other sites More sharing options...
AndyB Posted August 4, 2007 Share Posted August 4, 2007 @guyfromfl - it would really help if we knew what format your database dates use. Link to comment https://forums.phpfreaks.com/topic/63346-sql-date-function/#findComment-315726 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.