Home » RDBMS Server » Server Administration » Select Date_column from table where Date_column > 01/01/2000
Select Date_column from table where Date_column > 01/01/2000 [message #372435] Tue, 13 February 2001 14:22 Go to next message
Mike Oakes
Messages: 25
Registered: December 2000
Junior Member
Hello,

Forgive the question but i am new to SQL. I want to do a simple query that returns records where a date column is greater than a date. Such as
Select Date_column from table where Date_column > 01/01/2000.

When I do this i receive an error. inconsistent datatypes.

Can anyone specify the format I need to design this sql statement.

thanks for your help,
Mike Oakes
Re: Select Date_column from table where Date_column > 01/01/2000 [message #372437 is a reply to message #372435] Tue, 13 February 2001 14:49 Go to previous message
Bala
Messages: 205
Registered: November 1999
Senior Member
Hi,
The date datatype is stored in a native format
inside oracle.
when you want to compare some value(varchar/numeric) with a date column, you have to first convert your value into date datatype and then compare..
so you above example would be...
Select Date_column from table where Date_column > to_date('01/01/2000', 'MM/DD/YYYY');

to_date is function used for the date datatype conversion. the syntax for to_date is..
to_date('your_value', 'your_format')...

When you want to do reverse, you want to select a datecolumn to your screen(sqlplus, odbc etc...)

you have to convert them back to char datatype
EX.
select to_char(date_column, 'MM/DD/YYYY') from table;

Bala
Previous Topic: performance
Next Topic: explain plan
Goto Forum:
  


Current Time: Tue Jun 18 12:24:13 CDT 2024