Home » SQL & PL/SQL » SQL & PL/SQL » Add +1 to Date Field (Newbie to SQL and Oracle) (Oracle)
Add +1 to Date Field (Newbie to SQL and Oracle) [message #641856] Tue, 25 August 2015 17:38 Go to next message
bseismic
Messages: 1
Registered: August 2015
Location: Sac
Junior Member
Newbie here...

I'm trying to add +1 to a date field.

update XYZ_DETAILS det set det.parameter6 = det.parameter6 + 1 where det.XYZ_id = 38366

The value in det.parameter6 = 2015-08-27 00:00:00

sysdate + 1 from dual works.

Can't get the same approach to work on this table column.

Help

Thank you.
Re: Add +1 to Date Field (Newbie to SQL and Oracle) [message #641859 is a reply to message #641856] Tue, 25 August 2015 18:38 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Welcome to this forum

Please read and follow the forum guidelines, to enable us to help you:
OraFAQ Forum Guide
How to use {code} tags and make your code easier to read

post results from SQL below

SELECT TO_CHAR(SYSDATE,'YYYY-MM-DD HH24:MI:SS'), TO_CHAR(SYSDATE+1,'YYYY-MM-DD HH24:MI:SS') FROM DUAL;

SQL> DESC XYZ_DETAILS
Re: Add +1 to Date Field (Newbie to SQL and Oracle) [message #641860 is a reply to message #641859] Tue, 25 August 2015 18:40 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
post results from SQL below

SELECT det.parameter6, TO_CHAR(det.parameter6,'YYYY-MM-DD HH24:MI:SS'), TO_CHAR( det.parameter6+1,'YYYY-MM-DD HH24:MI:SS') FROM XYZ_DETAILS det
where det.XYZ_id = 38366;
Re: Add +1 to Date Field (Newbie to SQL and Oracle) [message #641862 is a reply to message #641856] Tue, 25 August 2015 19:20 Go to previous messageGo to next message
jaramill
Messages: 10
Registered: January 2000
Location: Glendale, AZ
Junior Member
bseismic wrote on Tue, 25 August 2015 15:38
Newbie here...

I'm trying to add +1 to a date field.

update XYZ_DETAILS det set det.parameter6 = det.parameter6 + 1 where det.XYZ_id = 38366

The value in det.parameter6 = 2015-08-27 00:00:00

sysdate + 1 from dual works.

Can't get the same approach to work on this table column.



I assume you know what adding an integer to a date field does? If not then, basically any integer (i.e. whole number) is equivalent to a full day. So if your current date in the column parameter6 = '2015-08-27 00:00:00' then you are basically wanting to "add" a day. As the first responder "Black Swan" mentions, what is the table description of xyz_details so we can the column definitions and datatypes. Is parameter6 a column with a datatype of "DATE" or is it a VARCHAR2 or CHAR string type?
Re: Add +1 to Date Field (Newbie to SQL and Oracle) [message #641870 is a reply to message #641856] Wed, 26 August 2015 06:20 Go to previous message
EdStevens
Messages: 1376
Registered: September 2013
Senior Member
Unfortunately, you've given us no actionable information.
We don't know what "Can't get the same approach to work on this table column." really means. Are you getting an error message? Are you getting results other than what you expected?
And we don't know the data type of det.parameter6, so we don't know what should result from adding 1 to it.
Previous Topic: Table partition
Next Topic: Query
Goto Forum:
  


Current Time: Wed Apr 24 04:19:23 CDT 2024