按时间排序存储为Varchar

时间:2014-02-17 13:26:47

标签: oracle to-date to-char

我有一个列(s_time)作为varchar。我存储了12个小时的时间(早上7点)。我想按此列(s_time)订购。 我试过这个oracle查询

select * from tabl_time order by to_date('s_time','hh12:mi') asc

但是这没用。 任何人都可以帮我这样做吗?

提前致谢。

2 个答案:

答案 0 :(得分:1)

你似乎错过了格式的AM / PM部分,可以用AM或PM表示(或者也可以用AM或PM表示,但我至少在小提琴中有点问题)

select * from table_time 
order by to_date(s_time, 'HH12:MI AM') asc

答案 1 :(得分:1)

to_date('s_time','HH12:MI AM') ASC
相关问题