Is it possible to use timestamp without having to convert to String in Oracle?

6

I have a query that one of your filters is a date, is it possible to filter in Oracle with something like this?

SELECT * FROM tabela WHERE campoData = '2014-02-10 15:56:00.000'

Or do we always have to convert to String as below?

SELECT * FROM tabela WHERE campoData = TO_DATE('10/02/2014 15:56:00','DD/MM/YYYY HH24:mi:ss')

I'm using Oracle 10g.

    
asked by anonymous 10.02.2014 / 18:57

1 answer

3

According to an Oracle documentation , there are date literals.

I made a very simple query to exemplify:

SELECT DATE '1998-12-25', TIMESTAMP '1984-03-01 09:26:50.124' FROM DUAL;

I got the following output in SQL Developer:

Accordingtothedocumentationitselfyoucandosomethinglike:

SELECT * FROM my_table WHERE datecol = DATE '2002-10-03';     
10.02.2014 / 19:12