RDPD
RDPD

Reputation: 565

SQL query doesnt bring out results when queried using date

I see that a table has the data value as 18-May-2012. But when I query looking for the same date using the below query, no results are available.

Select Submit_Dt From Siebel.S_Order_Dtl
where submit_dt = '18-May-2012'

Could you help me sort this issue?

Upvotes: 0

Views: 73

Answers (2)

user170442
user170442

Reputation:

You need to convert string date into date with TO_DATE() function. Also you need to take into account that your date might contain hours/minutes/seconds. In order to handle this you need to truncate submit_dt column.

In your case it would look like this:

Select Submit_Dt From Siebel.S_Order_Dtl
where TRUNC(submit_dt) = TO_DATE('18-May-2012','dd-MON-yyyy')

Upvotes: 1

Robert
Robert

Reputation: 25763

Try to convert the date to date format using to_date as below

Select Submit_Dt From Siebel.S_Order_Dtl
where submit_dt = to_date('18-May-2012','DD-MON-YYYY')

Upvotes: 1

Related Questions