Solved

Date Manipulation in PL/SQL

Posted on 2004-08-30
4
1,929 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to recover a database from a user managed backup

762 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

7 Experts available now in Live!

Get 1:1 Help Now