Date grading without time



  • Like, MySQL I want you to do the sorting before the day without counting time. Like we have dates:

    2015-02-12 10:01:02
    

    2015-02-12 23:01:02

    2015-01-12 23:01:02

    I only found this request, but it sorts on a date without counting the year and the month:

    SELECT * FROM news OREDER BY DAY(date), views

    I need to keep the grading time off because the grading will be the number of lookes per day.
    As an option, I've found a solution, but there may be something simple:

    SELECT *, DATE_FORMAT(date, '%Y-%m-%d') AS sort_date FROM news ORDER BY sort_date, views



  • function day() - That's it. https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_day ♪

    You're gonna need a date. https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date ♪

    For example:

    select * from news order by date(date), views
    

Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2