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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:26:21+00:00 2026-06-01T20:26:21+00:00

Like the title says I need to have a final result where on one

  • 0

Like the title says I need to have a final result where on one line I have
year- month and week…

Something like that:

------------------------
| Year | Month | Week  |  
| 2012 |   1   |   1   |  
| 2012 |   1   |   2   |  
| 2012 |   1   |   3   |  
| 2012 |   1   |   4   |  
| 2012 |   1   |   5   |  
| 2012 |   2   |   5   |  

And so on…

Is it possible to generate a view like this (also using some support table)?

  • 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-06-01T20:26:22+00:00Added an answer on June 1, 2026 at 8:26 pm

    You can do it with a stored procedure:

    DELIMITER $$
    
    CREATE PROCEDURE createDatesTable()
    BEGIN
    
    DECLARE FullDate date;
    
    DROP TABLE IF EXISTS dates;
    CREATE TABLE dates(
    date_key date NOT NULL,
    calendarYear int NOT NULL,
    calendarQuarter tinyint NOT NULL,
    calendarMonthNo int NOT NULL,
    calendarWeekNo tinyint NOT NULL,
    dayNumberOfMonth tinyint NOT NULL,
    dayNumberOfWeek tinyint NOT NULL,
    PRIMARY KEY (date_key));
    
    SET FullDate  = '2012-01-01';
    
    WHILE (FullDate <= '2012-12-31') DO 
    BEGIN
    
    INSERT INTO dates( 
        date_key,
        calendarYear,
        calendarQuarter,
        calendarMonthNo,
        calendarWeekNo,
        dayNumberOfMonth,
        dayNumberOfWeek
    )VALUES( 
        FullDate,
        YEAR(FullDate),
        QUARTER(FullDate),
        MONTH(FullDate),
        WEEK(FullDate, 1), /*Have a look at the WEEK() function in the manual!!!*/
        DAYOFMONTH(FullDate),
        DAYOFWEEK(FullDate)
    );
    
    SET FullDate = DATE_ADD(Fulldate, INTERVAL 1 DAY);
    END;
    END WHILE;
    END ;
    $$
    DELIMITER ;
    

    Then do a call createDatesTable()

    and you will have your table filled.

    Important: ypercube’s comment is right. You have to consider this. So have a look at the WEEK() function and its supported modes. Adjust the procedure accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, just like the title says, I need to create an application that gets
Like the title says I need to write a function that will sort a
The title pretty much says it all. I have a regex that I need
Basically what the title says... I need to have an image that when clicked,
Like the title says, I need a way to detect if the build is
As title says, I have a list of words, Like stopWords = [the, and,
as the title says, I would like to create a many-to-one relationship using Fluent
Basically, what the title says. I have several properties that combine together to really
As the title says, I want to have a build tool that quite much
Like the title says, I need to use php (wordwrap or whatever works) to

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.