select picking up the items that are in the current day and time

Asked

Viewed 45 times

0

I want to take items that are less than the current date and time, but when I run select from the error message, not a Valid Month. In the database the date is set as follows, '25/09/18 10:23'.

SELECT * FROM v_tpl_acompanhamento WHERE 
coleta_plan = TO_DATE('25/09/18 12:19', 'DD/MM/YY HH24:MM')

1 answer

0

The problem is in the date format, the correct would be 'DD/MM/YY HH24:MI', you are passing MM twice, so he is waiting twice a month.

Also remember, if you need to compare to the current date, just use Sysdate

  • I set the select, I put the MI in place of the MM but still keeps displaying the error message, not the Valid Month.

  • The way I was using the select was wrong. The correct is to format the column I want with to_date and then make the comparison, like this: SELECT * FROM v_tpl_accompaniment WHERE TO_DATE(coleta_plan, 'DD/MM/YY HH24:MI') = TO_DATE('25/09/18 12:19', 'DD/MM/YY HH24:MI')

Browser other questions tagged

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