Solved

Date Manipulation in PL/SQL

Posted on 2004-08-30
4
1,930 Views
Last Modified: 2012-05-05
Hi,

I'm trying to wright a script to take an oracle date and substract both 1 second and 2 seconds from it.

Here's my solution which works on my test database but not on production.

to_char(lAvailableCycleIterCurRec.END_DATE_TIME-1.1574074074074074074074074074074e-5,'yyyymmddhh24miss'));

Any help much appreciated.

Thanks,

Derek.
0
Comment
Question by:ruamire
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
cjjclifford earned 130 total points
ID: 11929590
What you've done is the equivalent to:

to_char(lAvailableCycleIterCurRec.END_DATE_TIME - ( 1 / ( 24 * 60 * 60 ) ), 'yyyymmddhh24miss' )

which is correct... what (if any) error is being produced on production, in comparision to Test, or describe what differences there are...
0
 
LVL 9

Assisted Solution

by:pratikroy
pratikroy earned 120 total points
ID: 11929912
Hi Derek,

what is the problem that u encounter on production ? Do you get an error ? if so, what error? If you dont get the desired result, then what is the result that you get ?

Have you checked whether the data type of the column - lAvailableCycleIterCurRec.END_DATE_TIME is same on TEST and PRODUCTION databases ?

Cheers !
0
 
LVL 9

Expert Comment

by:pratikroy
ID: 11929936
Can you try the following :

ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MON-DD HH24:MI:SS';

Select lAvailableCycleIterCurRec.END_DATE_TIME,
         lAvailableCycleIterCurRec.END_DATE_TIME-1.1574074074074074074074074074074e-5
From TableA;

Select sysdate, sysdate - 1.1574074074074074074074074074074e-5 from dual;

Hope this helps !

0
 
LVL 1

Author Comment

by:ruamire
ID: 11930029
I've changed it now to

to_date(lAvailableCycleIterCurRec.END_DATE_TIME, 'yyyymmddhh24miss' ) - (1/24/60/60));

The problem was that new date format came in, previously only the date was specified, now they specified date and time and our conversion was only 'yyyymmddhhmiss', not 'yyyymmddhh24miss'.

It caused problems all over the place!

Thanks for you help

Derek.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now