Solved

Date Manipulation in PL/SQL

Posted on 2004-08-30
4
1,943 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

724 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