Home » Infrastructure » Unix » substracting/change date value
substracting/change date value [message #261005] Tue, 21 August 2007 09:02 Go to next message
nashrul
Messages: 7
Registered: August 2007
Location: Indonesia
Junior Member
I have this snippet in korn shell. I would like to get last day of current date. So, I do the query below.

last_date=`sqlplus -s PUNDISM2/PUNDISM2@PUNDISM<<eof
set serveroutput on;
set pagesize 0;
set heading off;
set feedback off;
set linesize 1000;
select to_char(last_day(sysdate), 'YYYY-MM-DD') from dual;
EXIT;
eof`

The problem is the machine time is set 1 year in advance (I cannot change this since it is beyond my authority). So, i will get 2008-08-21 instead of 2007-08-21 from this query. I need to substract this by one year so I get the real last day of the current time. How can i do this ??
Re: substracting/change date value [message #261007 is a reply to message #261005] Tue, 21 August 2007 09:07 Go to previous messageGo to next message
Michel Cadot
Messages: 59427
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
SQL> select sysdate, add_months(sysdate,-12) a from dual;
SYSDATE             A
------------------- -------------------
21/08/2007 16:07:24 21/08/2006 16:07:24

1 row selected.

Regards
Michel
Re: substracting/change date value [message #261119 is a reply to message #261005] Tue, 21 August 2007 21:40 Go to previous message
nashrul
Messages: 7
Registered: August 2007
Location: Indonesia
Junior Member
thanks..it works...
Previous Topic: assign sql output to unix shell variable
Next Topic: Oracle Installation on Solaris
Goto Forum:
  


Current Time: Fri Oct 24 23:24:14 CDT 2014

Total time taken to generate the page: 0.13055 seconds