A
A
Almik Oh! Give me a guitar2015-02-12 09:03:38
Oracle
Almik Oh! Give me a guitar, 2015-02-12 09:03:38

Why is this query not working?

select extract( day from diff ) days,
          extract( hour from diff ) hours,
           extract( minute from diff ) minutes,
          extract( second from diff ) seconds
      from (select TO_TIMESTAMP('06-APR-82 11.56.11.000000 AM', 'DD.MM.YYYY HH24:MI:SS,FF') - TO_TIMESTAMP('21-DEC-47 11.56.11.000000 AM','DD.MM.YYYY HH24:MI:SS,FF') diff
             from dual)

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
Cipis, 2015-02-19
@Cipis

I advise you to get acquainted with the arithmetic of dates in oracle. The result of the date1-date2 operation will always be a number (number of days).

I
IceJOKER, 2015-02-12
@IceJOKER

It would be better if you wrote the text of the error, and not the text of the request, more useful

A
Almik Oh! Give me a guitar, 2015-02-12
@almyk

Got it! Returns the number of days

select extract( day from diff ) days,
          extract( hour from diff ) hours,
           extract( minute from diff ) minutes,
          extract( second from diff ) seconds
      from (select TO_TIMESTAMP('06-APR-2015 11.56.11.000000 AM','DD.MM.YYYY HH.MI.SS.FF AM') - TO_TIMESTAMP('06-APR-2014 11.56.11.000000 AM', 'DD.MM.YYYY HH.MI.SS.FF AM') diff
             from dual)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question