Oracle Date Format Mystery - Why is it not an acceptable format? -
i new sql have still written few queries similar 1 writing now. whatever reason when run query returned 'ora-01821: date format not recognized' error. looked , looked around here on stack , other places , believe syntax make sense confused why i'm thrown error.
my query runs based on day of month is. if 1st, should run 15th-last day of previous month. if 16th, should run 1st-15th of current month.
this code when first day of month:
select case when to_char(sysdate, 'yyyymmdd') = to_char(sysdate, 'yyyymm' || '01') (do lot of things) . . . end firstreportgroup *datetable* between between to_char(sysdate, 'yyyymm' || '16') , to_char(last_day(sysdate), 'yyyymmdd');
and code when 16th:
select case when to_char(sysdate, 'yyyymmdd') = to_char(sysdate, 'yyyymm' || '16') (do lot of things again) . . . end secondreportgroup *datetable* between to_char(sysdate, 'yyyymm' || '01') , to_char(sysdate, 'yyyymm' || '15')
it must kind of date formatting syntax error i'm not seeing. appreciate here , forward figuring out! let me know if need more info.
thanks.
two problems
- compare data types date on both or string on both not date , string
- two to_char works on date need
to_char(sysdate, 'yyyymm') || '16'
instead to_char works on date, you're concating in string that's not valid to_char function. after function.
Comments
Post a Comment