Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 989891
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:51:48+00:00 2026-05-16T05:51:48+00:00

I need to find some records created in a range of quarters. For example,

  • 0

I need to find some records created in a range of quarters. For example, I’m looking for all records created between the 4th quarter of 2008 and the 1st quarter of 2010. I have this in my WHERE-clause:

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

but Oracle says: ORA-01820: format code cannot appear in date input format. The Q is a valid date format symbol, so I’m not sure what’s happened. Is this even a valid way to find values in between calender quarters, or is there a better way?


Also interesting, and possibly related, if I execute this:

select to_date('2009','YYYY') from dual;

The value displayed in my IDE is 2009-08-01. I would have expected 2009-08-04, since today is 2010-08-04.

This:

select to_date('2009 1','YYYY Q') from dual;

of course, fails.

(Oracle 10g)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T05:51:49+00:00Added an answer on May 16, 2026 at 5:51 am

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

    See the second column of table 2.15 at http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements004.htm#i34948. Not all format elements are allowed when converting to dates, timestamps, etc.

    I recommend against using between for date range checks. People often will miss values within the ending day that the expect to be included. So I would translate:

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

    To

    and to_date('2008-10-01', 'YYYY-MM-DD') <= r.record_create_date 
    and record_create_date < to_date('2010-04-01', 'YYYY-MM-DD') -- < beginning of 2Q2010.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to find some way of displaying a drop-down menu that depending on
I need to find some strings that the current version of Windows is using.
Sometimes I need to find some strings inside DB usually it is just host-name
I need to find a way to pass some strings to my word 2003
I have some pdf documents and I need to find a way to automate
I'm working with some Google maps bounding box lon/lat points and need to find
Given some source file (or more generic - input stream), I need to find
I haven't done much multithreading before and now find the need to do some
Unfortunately, I often find I need to reboot to wipe some unhealthy Xcode state.
I need to expose some input fields based on what properties I find for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.