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
Solved

Date Manipulation in PL/SQL

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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle RAC 12c 8 87
Create table from select - oracle 6 53
oracle- set role and grant privileges 6 38
PL SQL Developer 7 53
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…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

856 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