CodeIgniter Forums
previous month records - 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: previous month records (/showthread.php?tid=5361)



previous month records - El Forum - 01-19-2008

[eluser]Sawariya[/eluser]
Hi friends..
how to retrieve previous month records from mysql database table...

thanks in advance


previous month records - El Forum - 01-19-2008

[eluser]Michael Wales[/eluser]
Code:
SELECT * FROM table WHERE MONTH(date_field) = MONTH(SUBDATE(CURDATE(), INTERVAL 1 MONTH))

I think that will work, just coming off the top of my head. Check out MySQL's date documentation.


previous month records - El Forum - 01-19-2008

[eluser]Sawariya[/eluser]
Thank you Michael Wales..


previous month records - El Forum - 01-19-2008

[eluser]Sawariya[/eluser]
thank you very much for your help....


previous month records - El Forum - 01-31-2008

[eluser]Sawariya[/eluser]
One more doubt ..
how to get previous month name according to server date..
its not from databse,,,?? i think its possible ...


previous month records - El Forum - 02-04-2008

[eluser]Sawariya[/eluser]
Hi Michael Wales
Thanks for your help..
This is working... but i its not checking year...