Grid with selected data of a period.

Grid with selected data of a period.

Hi I have a table reservation in which I check out a date, that is the last night of stay at the hotel.
I would like to create a grid that opening I automatically calls all reservations have to check out in the past month.
How can I put the temporal condition in opening the grid?

simply select your records by sql select last month

SELECT * FROM table
WHERE YEAR(date_created) = YEAR(CURRENT_DATE - INTERVAL 1 MONTH)
AND MONTH(date_created) = MONTH(CURRENT_DATE - INTERVAL 1 MONTH)

here
http://stackoverflow.com/questions/2090221/mysql-query-to-get-all-rows-from-previous-month

thank you, it’s perfect.
Last question, then by varying the interval;
INTERVAL 1 MONTH
with
INTERVAL 2 MONTH
automatically go back two months?

Peraziende,

Google is our friend.

http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html

Dave

[QUOTE=peraziende;33364]thank you, it’s perfect.
Last question, then by varying the interval;
INTERVAL 1 MONTH
with
INTERVAL 2 MONTH
automatically go back two months?[/QUOTE]

yes it will load the data exactly as stated in your SQL with the date/time given when the application is started

as Dave said, you may need to read about it, as there are many approaches and many codes do this, try some of them before choosing what to use for your project, it is good approach to test, and keep testing next month to see what those code will do in case of the month is over…etc.