PL/SQL working with dates

360 pts.
Tags:
PL/SQL date issues
I have a table with a varchar2 field. The field contains '07/2012' with represents a month/year value. There are multiple dates in the table. I have a SELECT that is to read the table , comparing the date value against a date value input by the users. This is defined as DATE. The SELECT doesnt work. I keep getting ORA-01841: (full) year must be between -4713 and +9999, and not be 0. THIS IS THE SELECT:
v_from_date date;

v_to_date date;

month_year is the table is definied as VARCHAR2(7)

(select distinct(center_code),
center_name,
center_nddr,
0,0,0,0,0
from mytable        where donor_number is null
and to_date(month_year, 'mm/yyyy') between to_date(v_from_date, 'mm/yyyy')
and to_date(v_to_date, 'mm/yyyy'));
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 1  Reply

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • carlosdl
    Are you certain that all records have correct data for that field?

    Also, if your query is converting v_from_date and v_to_date to DATE type, they should be varchars not dates.
    84,805 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: