Home » SQL & PL/SQL » SQL & PL/SQL » query (oracle 10g)
query [message #389137] Fri, 27 February 2009 06:36 Go to next message
rajasekhar857
Messages: 500
Registered: December 2008
Senior Member
hi,

i am having a query like this.
select TO_CHAR(appointment_Date,'DD-MM-YYYY HH:MI:SS AM') from emrencounterdetails.

the o/p shows like this

28-01-2009 12:00:00 AM
28-01-2009 12:00:00 AM
28-01-2009 12:00:00 AM

what i want is the current time needed to put in that.can you guide me how to change that
Re: query [message #389139 is a reply to message #389137] Fri, 27 February 2009 06:46 Go to previous messageGo to next message
joicejohn
Messages: 327
Registered: March 2008
Location: India
Senior Member
@rajasekhar857,

You mean you want to concatenate the date with something like

SQL> SELECT to_char(sysdate, 'HH24:MI:SS') FROM Dual;

TO_CHAR(
--------
18:29:28


Regards,
Jo
Re: query [message #389143 is a reply to message #389139] Fri, 27 February 2009 07:05 Go to previous messageGo to next message
rajasekhar857
Messages: 500
Registered: December 2008
Senior Member
its working fine with
SELECT to_char(sysdate,'DD-MM-YYYY HH24:MI:SS PM') FROM emrencounterdetails;

showing o/p as
27-02-2009 18:35:02 PM

but for this its not showing correctly

SELECT to_char(appointment_date,'DD-MM-YYYY HH24:MI:SS PM') FROM emrencounterdetails;

showing o/p as
28-01-2009 00:00:00 AM

can you tell me why it is happening like this
Re: query [message #389144 is a reply to message #389143] Fri, 27 February 2009 07:08 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
Because your appoinment date column has got a time element value of 00:00:00 AM
Presumably, when someone inserted the values, they did not include a time.
Re: query [message #389145 is a reply to message #389144] Fri, 27 February 2009 07:12 Go to previous messageGo to next message
rajasekhar857
Messages: 500
Registered: December 2008
Senior Member
so what is the solution for this what i have to do for gaetting that specified time format
Re: query [message #389147 is a reply to message #389145] Fri, 27 February 2009 07:14 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
Your column does Not contain time (effectively) do you have another (different) column that contains the appointment time by any chance?
Re: query [message #389149 is a reply to message #389145] Fri, 27 February 2009 07:16 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
You can't - that data does not exist.
When the appointment_date column was populated, the time component was removed (or not included).
Re: query [message #389150 is a reply to message #389149] Fri, 27 February 2009 07:17 Go to previous message
rajasekhar857
Messages: 500
Registered: December 2008
Senior Member
thanks for your suggesions
Previous Topic: dynamic sql issue
Next Topic: DAY and DY functions
Goto Forum:
  


Current Time: Sat Dec 07 00:07:09 CST 2024