Q:

SQL How do I extract time from a date to HH:MI:SS PM/AM?

I want to change a format of the dates to format HH:MI:SS PM/AM in SQL Oracle.
I want to use it in case when like this:
case when to_char(a.dtime,'HH:MI:SS') >= 12:00:00 then to_char(a.dtime,'HH:MI:SS PM') else null end as date
but SQL does not want to show me all to_char times > 12:00 but it shows only those where there is 12:%%:%%.
And it does not work with to_date.
Any suggestions? Thanks a lot in advance.

A:

You can use TO_CHAR( datetime, format ) to format a DATE column. The format options are given here.
This would give you the time part of a date value (12-hour clock plus AM/PM):
SELECT TO_CHAR( column_name,'HH:MI:SS AM') 
FROM   your_table

Edit - Addressing the update
You can do:
SELECT CASE WHEN TO_NUMBER( TO_CHAR( a.dtime_appl_creation, 'HH24' ) ) >= 12
            THEN TO_CHAR( a.dtime, 'HH:MI:SS PM' )
            END AS "date"
FROM   table_name

