![]() |
subtract from date. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: subtract from date. (/showthread.php?tid=34389) |
subtract from date. - El Forum - 09-28-2010 [eluser]snortop[/eluser] Thise problem really anoy me. Im trying to subtract 6 month from current date. But it keep telling me errors. Code: $this->db->where('timestamp <', DATE_SUB(now() , INTERVAL 6 month)); timestamp = timestamp anyone have a working code or where i can figur out have to do these. subtract from date. - El Forum - 09-28-2010 [eluser]danmontgomery[/eluser] Code: $this->db->where('timestamp < DATE_SUB(NOW(), INTERVAL 6 MONTHS)', NULL, FALSE); subtract from date. - El Forum - 09-28-2010 [eluser]snortop[/eluser] ROFL... so easy have could i have missed that subtract from date. - El Forum - 09-28-2010 [eluser]Dennis Rasmussen[/eluser] DATE_SUB() is an SQL function, but you're running it in PHP. Code: $this->db->where('timestamp <', 'DATE_SUB(now() , INTERVAL 6 MONTH)'); If I'm wrong then please tell me what kind of error you get. subtract from date. - El Forum - 09-28-2010 [eluser]snortop[/eluser] Well.. first i keep getting parsing error. Seach the web for some other way to work around. so i did finde some code and tried whit variable like. Code: $date = new DateTime(); and Code: $date = new datetime(); error Code: Severity: 4096 So i wrote here... just the 1 line i had first. Then i though i had it whit the other code... didnt get error first time Had die(); in it. Then i got these error.: Code: A Database Error Occurred subtract from date. - El Forum - 09-28-2010 [eluser]snortop[/eluser] dont get a error anymore, but the other code not working.. that another problem. Would hear have someone/anyone else would do it ;-) subtract from date. - El Forum - 09-28-2010 [eluser]snortop[/eluser] Well my code keep deleting new post.. so something still wrong in it. |