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 6948029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:46:10+00:00 2026-05-27T13:46:10+00:00

How to Create a View with all days in year. view should fill with

  • 0

How to Create a View with all days in year. view should fill with dates from JAN-01 to Dec-31. How can I do this in Oracle ?

If current year have 365 days,view should have 365 rows with dates. if current year have 366 days,view should have 366 rows with dates. I want the view to have a single column of type DATE.

  • 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-27T13:46:10+00:00Added an answer on May 27, 2026 at 1:46 pm

    This simple view will do it:

    create or replace view year_days as
    select trunc(sysdate, 'YYYY') + (level-1) as the_day
    from dual
    connect by level <= to_number(to_char(last_day(add_months(trunc(sysdate, 'YYYY'),11)), 'DDD'))
    /
    

    Like this:

    SQL> select * from year_days;
    
    THE_DAY
    ---------
    01-JAN-11
    02-JAN-11
    03-JAN-11
    04-JAN-11
    05-JAN-11
    06-JAN-11
    07-JAN-11
    08-JAN-11
    09-JAN-11
    10-JAN-11
    11-JAN-11
    
    ...
    
    20-DEC-11
    21-DEC-11
    22-DEC-11
    23-DEC-11
    24-DEC-11
    25-DEC-11
    26-DEC-11
    27-DEC-11
    28-DEC-11
    29-DEC-11
    30-DEC-11
    31-DEC-11
    
    365 rows selected.
    
    SQL> 
    

    The date is generated by applying several Oracle date functions:

    • trunc(sysdate, 'yyyy') gives us the first of January for the current year
    • add_months(x, 11) gives us the first of December
    • last_day(x) gives us the thirty-first of December
    • to_char(x, 'DDD') gives us the number of the thirty-first of December, 365 this year and 366 next.
    • This last figure provides the upper bound for the row generator CONNECT BY LEVEL <= X
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a page by using view 2. This page list all
This is my query, CREATE VIEW employee_vu AS( SELECT employee_id,last_name employee,department_id FROM employees); I
I know you can create a basic view to do this, but what I
My create view code like this create VIEW [dbo].[vw_test] AS SELECT 'B' AS rtype,
How can I create View on Linked Server db. For Example I have a
I am trying to create a menu where users can view a menu that
I've been working on this for days and I can't find a proper solution,
I am trying to create a list of birth days, ordered by the dates,
I want all labels inside a detail view to be bold. I created a
I have a problem with the Create View in the SimpleRepository example in Subsonic

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.