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

Asked

Viewed 401 times

6

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

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

Or 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.

  • Philippe, you are referring to queries executed within a software client like SQL Developer or Toad? Or are you thinking about some programming language?

  • Client even, in Java I use java.sql.Timestamp and it turns to me.

1 answer

3


According to a oracle documentation there are the date literals.

I put together a simple query to illustrate:

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

I got the following output in SQL Developer:

inserir a descrição da imagem aqui

According to the documentation itself you can do something like:

SELECT * FROM my_table WHERE datecol = DATE '2002-10-03';

Browser other questions tagged

You are not signed in. Login or sign up in order to post.