|
|
|
Re: Sql query showing time problem [message #604886 is a reply to message #604885] |
Sun, 05 January 2014 09:27 |
flyboy
Messages: 1903 Registered: November 2006
|
Senior Member |
|
|
I see no need of VARCHAR2-DATE-VARCHAR2 conversion. If you "know" that OUT_TIME is always 'pm' (and IN_DATE always 'am' except 12:whatever), why not simply concatenate it to the column content?
select in_time||case when substr(in_time, 1,2) = '12' then ' pm' else ' am' end in_time,
out_time||' pm' out_time
from emp_test;
You may change the CASE expression for any logic determining the am/pm/fm/whatever value. And do not be surprised when it contains any garbage - it is the benefit of VARCHAR2 data type.
It would be nice if the "front-end application" would be fixed to store data in format you want to report.
Or, much better, store dates as DATE data type (with proper change of its treating).
(and yes, whoever designed that cr*p should be fired for incompetency)
|
|
|