[PHP] How to delete 3 months old records in my database?

2013-08-02 Thread Karl-Arne Gjersøyen
Hello again, folks! I wish to delete records in my database that is older than 3 months. $todays_date = date('Y-m-d'); $old_records_to_delete = ??? if($old_records_to_delete){ include(connect.php); $sql = DELETE FROM table WHERE date = '$old_records_to_delete'; mysql_query($sql, $connect_db) or

Re: [PHP] How to delete 3 months old records in my database?

2013-08-02 Thread Dušan Novaković
$query = DELECT FROM `__table_name__` WHERE `__date__` BETWEEN NOW() - INTERVAL 3 MONTH AND NOW() On Fri, Aug 2, 2013 at 12:58 PM, Karl-Arne Gjersøyen karlar...@gmail.comwrote: Hello again, folks! I wish to delete records in my database that is older than 3 months. $todays_date =

Re: [PHP] How to delete 3 months old records in my database?

2013-08-02 Thread Simon Griffiths
Hello, Try something like: $oldDate = new DateTime(); $oldDate-sub(new DateInterval('P3M')); $old_records_to_delete = $oldDate-format('Y-m-d'); Hope this helps, Si Sent from my iPhone On 2 Aug 2013, at 11:58, Karl-Arne Gjersøyen karlar...@gmail.com wrote: Hello again, folks! I wish to

Re: [PHP] How to delete 3 months old records in my database?

2013-08-02 Thread Karl-Arne Gjersøyen
2013/8/2 Dušan Novaković ndu...@gmail.com $query = DELECT FROM `__table_name__` WHERE `__date__` BETWEEN NOW() - INTERVAL 3 MONTH AND NOW() This delete everything from now and 3months backwards. I want to store 3 months from now and delete OLDER than 3 months old records. Karl

Re: [PHP] How to delete 3 months old records in my database?

2013-08-02 Thread Simon Schick
On Fri, Aug 2, 2013 at 2:02 PM, Karl-Arne Gjersøyen karlar...@gmail.com wrote: 2013/8/2 Dušan Novaković ndu...@gmail.com $query = DELECT FROM `__table_name__` WHERE `__date__` BETWEEN NOW() - INTERVAL 3 MONTH AND NOW() This delete everything from now and 3months backwards. I want to

Re: [PHP] How to delete 3 months old records in my database?

2013-08-02 Thread Dušan Novaković
Yeah, just spelling mistake :-) And yes, it should be: $query = DELETE FROM `__table_name__` WHERE `__date__` = NOW() - INTERVAL 3 MONTH Cheers ;-) On Fri, Aug 2, 2013 at 2:35 PM, Simon Schick simonsimc...@gmail.com wrote: On Fri, Aug 2, 2013 at 2:02 PM, Karl-Arne Gjersøyen