Showing posts with label oracle. Show all posts
Showing posts with label oracle. Show all posts

Wednesday, February 23, 2011

Calculate TIME Difference in single sql query

SELECT
TRUNC(DATES.START_DATE - DATES.END_DATE) ||' DAYS '||
TRUNC((DATES.START_DATE - DATES.END_DATE) * 24 - TRUNC(TO_NUMBER(DATES.START_DATE - DATES.END_DATE)) * 24) ||' HOURS '||
TRUNC((TO_NUMBER(DATES.START_DATE - DATES.END_DATE) * 24 - TRUNC(TO_NUMBER(DATES.START_DATE - DATES.END_DATE) * 24))*60) ||' MINUTES '||
ROUND((((TO_NUMBER(DATES.START_DATE - DATES.END_DATE) * 24 - TRUNC(TO_NUMBER(DATES.START_DATE - DATES.END_DATE) * 24))*60) -
(TRUNC((TO_NUMBER(DATES.START_DATE - DATES.END_DATE) * 24 - TRUNC(TO_NUMBER(DATES.START_DATE - DATES.END_DATE) * 24))*60)))*60) ||' SECONDS ' AS TIME_DIFFERENCE

FROM (
SELECT TO_DATE('20110102123421', 'YYYYMMDDHH24MISS') AS START_DATE, TO_DATE('20110101101723', 'YYYYMMDDHH24MISS') AS END_DATE FROM DUAL
)DATES




OUTPUT : 1 DAYS 2 HOURS 16 MINUTES 58 SECONDS

Just change the dates in the outer sub query and with your own time format.
Enjoy..

Monday, October 18, 2010

PLSQL Developer Error - SQL*Net not properly installed [SOLVED]

Hello friends..

If you are using PLSQL developer to connect to the ORACLE database may have faced the problem "SQL*Net not properly installed".

This problem occur beacause ORACLE_HOME and the oci.dll path location may not have been configured in the preferences.

To do this, go to Tools>Preferences.

Now set the Oracle Home as the location of the ORACLE_HOME variable or where the Oracle is installed. In my case it is:

C:\Oracle\DataBase\product\10.2.0\db_1

After this set the oci.dll file location just under the Oracle Home text field.In my case it is:

C:\Oracle\DataBase\product\10.2.0\db_1\bin\oci.dll

click Apply>OK

Now restart the PLSQL developer. This should solve the problem.

Cheers..