Home > Back-end >  TO_DATE format SQL
TO_DATE format SQL

Time:11-24

I'm beginner. I have a problem that I can't solved. I would like to add the arguments for DATE. But I have an exception: ORA-01830: date format picture ends before converting entire input string. My code is below.

AND 
TO_DATE(so.org_due_date,'DD-MM-YYYY') >= ('01-11-2021')

Can somebody give tips how can I add this arguments? Thanks every1 for help. I appreciate that.

CodePudding user response:

Assuming that the org_due_date column be text, containing text dates in the format DD-MM-YYYY, the comparison should be:

TO_DATE(so.org_due_date, 'DD-MM-YYYY') >= date '2021-11-01';

While the input to the TO_DATE() function is text in the format DD-MM-YYYY, one valid Oracle date literal takes the format given above.

CodePudding user response:

Assuming that so.org_due_date is a DATE datatype, the TO_DATE function should be used on the right side.

AND so.org_due_date >= TO_DATE('01-11-2021', 'DD-MM-YYYY')

Or use a date literal in the YYYY-MM-DD format.

AND so.org_due_date >= DATE'2021-11-01'
  • Related