Вопрос

I have a table in oracle 'punch' where punching data is stored. 'punchtime' column is having the data as varchar2 and time is stored(like 20:30:00). when i want to sort the data by punchtime I use this query

 select * from punch order by to_date(punchtime,'hh24:mi:ss')

This works perfectly. But the below query does not work

select * from punch where punchtime = to_date('01:00:00','hh24:mi:ss')

It shows "not a valid month"

Can anyone please help me. I have to query this column.

Это было полезно?

Решение

As because punchtime is varchar2 datatype column, You need to query :

select * from punch where to_date(punchtime,'hh24:mi:ss') = to_date('01:00:00','hh24:mi:ss')
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top