Home » SQL & PL/SQL » SQL & PL/SQL » Please help
Please help [message #2771] Mon, 12 August 2002 13:21 Go to next message
Newie
Messages: 5
Registered: November 2001
Junior Member
I need to add 11 hours onto a column.
Now this column is in the format of DD-MM-YYYY HH:MMM:SS...My problem is adding the 11 hours on but also altering the DD-MM-YYYY with accordance to additional 11 hours for eg it turns over to the next day...is there any possible way of doing this.....
Re: Please help [message #2772 is a reply to message #2771] Mon, 12 August 2002 13:46 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
What is the datatype of this column - date or varchar2? If it is date, the update is very easy. If not, you have made life much harder on yourself.

If date:

update t
   set c = c + (11/24);


If varchar2: What is that datetime format? What is MMM? Why 3 Ms? Here is an answer for a valid format (MI instead of MMM):

update t
   set c = to_char(to_date(c, 'DD-MM-YYYY HH24:MI:SS') + (11/24), 'DD-MM-YYYY HH24:MI:SS');
Re: Please help [message #2774 is a reply to message #2771] Mon, 12 August 2002 15:15 Go to previous messageGo to next message
Newie
Messages: 5
Registered: November 2001
Junior Member
Thanks todd I will give that a try

With the format that was a typo, the column is a Date format and I will give your suggestion a try....

I appreciate your help....
Re: Please help [message #2874 is a reply to message #2771] Mon, 19 August 2002 08:47 Go to previous message
Abul Fazal
Messages: 39
Registered: February 2002
Member
Select to_char(sysdate, 'DD-MON-YYYY HH24:MI:SS '),
to_char((SYSDATE + (11/24)), 'DD-MON-YYYY HH24:MI:SS')
from dual
Previous Topic: rowtype var to pass as parameter to procedure?
Next Topic: passing index-by tables to stored procedure
Goto Forum:
  


Current Time: Thu Apr 25 08:40:52 CDT 2024