I have a column,PLAY_TIME, in my database which Im using to hold the time, hour, of a scheduled event. For example, PLAY_TIME, holds the values, 9:00AM, 9:15AM 10:00AM etc...
The PLAY_TIME column was set up as a VARCHAR data type, by the previous developer.
The problem is that when I try to sort this data in my sql statement, ORDER BY PLAY_TIME , the sort order is incorrect. Because the column type is VARCHAR, the items are being interpreted the the value of their first character, so its showing 10:00 AM before 9:00AM as 1 is less than 9.
How can I sort the times approriately? I know that if the column type is converted to a DATETIME data type, this would sort properly, however, the problem then is that the data is inserted into the column and I simply need times (hours) stored in the column.
Can anyone suggest a solution, hopefully quick and easy.
thanks for any help
The PLAY_TIME column was set up as a VARCHAR data type, by the previous developer.
The problem is that when I try to sort this data in my sql statement, ORDER BY PLAY_TIME , the sort order is incorrect. Because the column type is VARCHAR, the items are being interpreted the the value of their first character, so its showing 10:00 AM before 9:00AM as 1 is less than 9.
How can I sort the times approriately? I know that if the column type is converted to a DATETIME data type, this would sort properly, however, the problem then is that the data is inserted into the column and I simply need times (hours) stored in the column.
Can anyone suggest a solution, hopefully quick and easy.
thanks for any help