Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2015

    Unanswered: Problem in mysql query for sorting Time in hms format


    I am trying to sort the data in Mysql descendingly based on the time for videos.

    I have Video_Duration column in my database in which I store the time for videos in hms format( For example 1h54m3s, 9m3s, 0m3s).

    When i try to sort the database using the query below I am getting the output like 9m0s, 9m0s first instead of time with more time(like 1h35m29s).

    I am using the following query to sort the database

    $sql = "select * from videos where Category_Name='$category' ORDER BY Video_Duration DESC limit 50";
    Can you guys help me solve the problem


    Vishal Ved

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    Store the duration of the item in the suitable datetimr datatype.
    If you must store this sort of data in a text / string datatype then format it appropriately with leading 0

    Eg 9m0s, assumimg you have hours elsewhere becomes 00h09m00s
    Or if you prefer 00:09:00
    I'd rather be riding on the Tiger 800 or the Norton

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts