Which two SQL statements would give the required output?

You need to calculate the number of days from 1st Jan 2007 till date: Dates are stored in
the default format of dd-mm-rr. Which two SQL statements would give the required output?
(Choose two.)

You need to calculate the number of days from 1st Jan 2007 till date: Dates are stored in
the default format of dd-mm-rr. Which two SQL statements would give the required output?
(Choose two.)

A.
SELECT SYSDATE – TO_DATE(’01-JANUARY-2007′) FROM DUAL

B.
SELECT SYSDATE – ’01-JAN-2007′ FROM DUAL

C.
SELECT TO_DATE(SYSDATE,’DD/MONTH/YYYY’)-’01/JANUARY/2007′ FROM DUAL;

D.
SELECT SYSDATE – TO_DATE(’01/JANUARY/2007′) FROM DUAL;

E.
SELECT TO_CHAR(SYSDATE,’DD-MON-YYYY’)-’01-JAN-2007′ FROM DUAL;



Leave a Reply 1

Your email address will not be published. Required fields are marked *


helion

helion

alter session set nls_date_format = ‘dd-mm-rr’;

Session alterado.

SELECT SYSDATE – TO_DATE(’01/JANUARY/2007′) FROM DUAL;

SYSDATE-TO_DATE(’01/JANUARY/2007′)
—————————————
3.7E+03

SELECT SYSDATE – ’01-JAN-2007′ FROM DUAL;

Erro a partir da linha : 9 no comando –
SELECT SYSDATE – ’01-JAN-2007′ FROM DUAL
Relatório de erros –
Erro de SQL: ORA-01722: invalid number
01722. 00000 – “invalid number”
*Cause: The specified number was invalid.
*Action: Specify a valid number.

SELECT TO_DATE(SYSDATE,’DD/MONTH/YYYY’) – ’01/JANUARY/2007′ FROM DUAL;

Erro a partir da linha : 11 no comando –
SELECT TO_DATE(SYSDATE,’DD/MONTH/YYYY’) – ’01/JANUARY/2007′ FROM DUAL
Relatório de erros –
Erro de SQL: ORA-01843: not a valid month
01843. 00000 – “not a valid month”
*Cause:
*Action:

SELECT SYSDATE – TO_DATE(’01/JANUARY/2007′) FROM DUAL;

SYSDATE-TO_DATE(’01/JANUARY/2007′)
—————————————
3.7E+03

SELECT TO_CHAR(SYSDATE,’DD-MON-YYYY’)-’01-JAN-2007′ FROM DUAL;

Erro a partir da linha : 15 no comando –
SELECT TO_CHAR(SYSDATE,’DD-MON-YYYY’)-’01-JAN-2007′ FROM DUAL
Relatório de erros –
Erro de SQL: ORA-01722: invalid number
01722. 00000 – “invalid number”
*Cause: The specified number was invalid.
*Action: Specify a valid number.