sql - Oracle to_date function with quarter-format -


I need to find some records created in a range of quarters. For example, i was in the fourth quarter of 2008 and 2010 I am looking for all the records created between the first quarter of this year. I have this in WHERE-clause:

  ... and between r.record_create_date ('2008 4', 'YYYY Q') and to_date ('2010 1', 'YYYY Q ')  

But Oracle says: ORA-01820: Format code can not be displayed in the date input format . Q is a valid date format symbol, so I'm not sure what has happened. Is this a valid way of finding values ​​between calendars quarters, or is there a better way?


This is also interesting, and possibly related, if I execute it:

 Selection of 'code' to_date ('2009', 'YYYY') Do;  

The value displayed in my IDE is 2009-08-01 I hope 2009-08-04 to today is 2010-08-04 .

Select this:

  Dual to date ('200 1', 'YYY Q)';  

Definitely fails.

(Oracle 10G)

Oracle says: ORA-01820: Format code date can not appear in input format . Q is a valid date format symbol, so I'm not sure what's happened.

See the second column of Table 2.15. All format elements are not allowed when changed in dates, timestamps, etc.

I advise against using date range checks, people will often remember the values ​​in the days that are ending, which is expected to be included. Then I will translate: r.record_create_date between

  and between_date ('2008 4', 'YYYY Q') and to_date ('2010 1', 'YYYY Q')  

to

  and to_date ('2008-10-01', 'YYYY-MM-DD') & lt; = R.record_create_date and record_create_date & lt; To_date ('2010-04-01', 'YYYY-MM-DD') - & lt; Beginning of 2Q2010  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -