Solved

Convert military time to regular in oracle

Posted on 2014-01-15
3
854 Views
Last Modified: 2014-01-15
select sch_date,sch_time,
       site_id,first_name,last_name
  from hbc_donor_schedule hds
 where SCH_DATE = trunc(sysdate)
   AND STATUS = 'CNFRM'
   AND PROC_CODE = 'WB'
   AND DRIVE_ID IS NULL
   and donation_type = 'AL'

This is how my data is stored in the table. I want to order by sch_time asc. How can I convert to regular time and then order by?

SCH_DATE,SCH_TIME,SITE_ID,FIRST_NAME,LAST_NAME

1/15/2014,17:00:00,LOCN100326,SANDRA,FERRIS

1/15/2014,17:40:00,LOCN200034,DEBRA,GUARASCIO

1/15/2014,12:00:00,LOCN100024,KEITH,HOELTERHOFF

1/15/2014,17:00:00,LOCN101661,DARCY,KAROUZOS
0
Comment
Question by:anumoses
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 250 total points
ID: 39782572
Expected results?

Convert what you have to a date then back to a string.

Something like:
to_char(to_date(sch_time,'HH24:MI:SS'),'HH:MI:SS AM')

Order just by the date conversion:
to_date(sch_time,'HH24:MI:SS')
0
 
LVL 77

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 250 total points
ID: 39782601
I figured maybe I had better show the date and time just in case:

to_char(to_date(SCH_DATE || SCH_TIME,'MM/DD/YYYYHH24:MI:SS'),'MM/DD/YYYY HH:MI:SS AM')

Then the order:
to_date(SCH_DATE || SCH_TIME,'MM/DD/YYYYHH24:MI:SS')
0
 
LVL 6

Author Closing Comment

by:anumoses
ID: 39782641
Thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question