Skip to content
Advertisement

How to extract time in HH24:MM from varchar in Oracle

I have a column in the following varchar format. I would like to extract the time based on a condition e.g. < 7:00.

Table1
Column: timer(varchar)
23:45
05:00
07:00
22:00

Expected output
    test
    05:00
    07:30

I tried the following:

Select *
FROM Table1
where timer < 7:00

However, the result is not as expected.

Advertisement

Answer

Oracle does not have a time date, so presumably the type is a string.

Use string comparisons:

where time < '07:00'

Note that the leading 0 is important!

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement