Announcement

Collapse
No announcement yet.

How to make the current month's rows default in the grid ?

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

  • How to make the current month's rows default in the grid ?

    Here's my SQL ...
    SELECT monthname(start_date), start_date,title,description,start_time,end_time FROM sd_events;

    How do I make sure the current month's rows always appear in the grid first?
    I do not want to filter the other's month's events as I want the user to scroll to other months' events if they want.

  • #2
    Hi,
    if you don't have any future dates in the table it's just a ORDER BY start_date DESC at the end of your statement.

    jsb

    Comment


    • #3
      Originally posted by jsbinca View Post
      Hi,
      if you don't have any future dates in the table it's just a ORDER BY start_date DESC at the end of your statement.

      jsb

      Thanks. But that's not it.
      Let says that I have Jan to Dec events in the calendar.
      It is March now. I want the March events to default in the Grid.
      How do I do that without filtering the other events.
      The user should be able to scroll to Feb, Jan events or April, May etc events.

      Comment


      • #4
        You can use a virtual field to be your priority like the sample below(When the month of your date is equal current date month your priority field will be one so you order by priority field ASC):

        SELECT id, CASE WHEN MONTH(birhdate)=MONTH(CURRENT_DATE) THEN 1 ELSE 2 END AS priority
        FROM people ORDER BY 2 ASC

        This sample was tested with mysql.

        Comment

        Working...
        X