Announcement

Collapse
No announcement yet.

Grid with selected data of a period.

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?

  • #2
    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/2...previous-month

    Comment


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

      Comment


      • #4
        Peraziende,

        Google is our friend.

        http://dev.mysql.com/doc/refman/5.5/...functions.html

        Dave
        Dave Prue
        Code Whisperer
        Lahar International Corp
        www.lahar.net

        Comment


        • #5
          Originally posted by peraziende View Post
          thank you, it's perfect.
          Last question, then by varying the interval;
          INTERVAL 1 MONTH
          with
          INTERVAL 2 MONTH
          automatically go back two months?
          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.

          Comment

          Working...
          X