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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:46:22+00:00 2026-06-12T01:46:22+00:00

I’m trying to generate monthly records in one table based on instructions in another

  • 0

I’m trying to generate monthly records in one table based on instructions in another table. Software – MS Access 2007, though I’m looking for an SQL solution here. To greatly simplify the matter, let’s say the following describes the tables:

 TaskManager:
  - DayDue
  - TaskName

 Task:
  - DateDue
  - TaskName

So what happens is that there may be an entry in TaskManager {15, “Accounts due”}, so this should lead to an “Account due” record in the Task table with the due date being the 15th of each month. I’d want it to create records for the last few months and the next year.

What I’m thinking that I need to do is first create a SELECT query that results in x records for each record in the TaskManager table, with a date for each month. After that, I do an INSERT query which inserts records into the Task table if they do not EXIST in the aforementioned SELECT query.

I think I can manage the INSERT query, though I’m having trouble figuring out how to do the SELECT query. Could someone give me a pointer?

  • 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-12T01:46:23+00:00Added an answer on June 12, 2026 at 1:46 am

    Here is the solution I developed using Remou’s Calendar table idea.

    First create a Calendar table, which simply contains all dates for a desired range. It’s easy to just make the dates in Excel and paste them into the table. This is also a very reliable way of doing it, as Excel handles leap years correctly for the modern range of dates.

    After building this table, there are three queries to run. The first is a SELECT, which selects every possible task generated by the TaskManager based on the date and frequency. This query is called TaskManagerQryAllOptions, and has the following code:

    SELECT TaskManager.ID, Calendar.CalendarDate
    FROM TaskManager INNER JOIN Calendar ON
            TaskManager.DateDay = Day(Calendar.CalendarDate)
    WHERE (TaskManager.Frequency = "Monthly")
        OR (TaskManager.Frequency = "Yearly" AND
                TaskManager.DateMonth = Month(Calendar.CalendarDate))
        OR (TaskManager.Frequency = "Quarterly" AND
                (((Month(Calendar.CalendarDate)- TaskManager.DateMonth) Mod 3) =  0));
    

    The bulk of the above is to cover the different options a quarterly Day and Month pair could cover. The next step is another SELECT query, which selects records from the TaskManagerQryAllOptions in which the date is within the required range. This query is called TaskManagerQrySelect.

    SELECT TaskManagerQryAllOptions.ID, TaskManager.TaskName,
            TaskManagerQryAllOptions.CalendarDate
    FROM TaskManagerQryAllOptions INNER JOIN TaskManager
            ON TaskManagerQryAllOptions.ID = TaskManager.ID
    WHERE (TaskManagerQryAllOptions.CalendarDate > Date()-60)
        AND (TaskManagerQryAllOptions.CalendarDate < Date()+370)
        AND (TaskManagerQryAllOptions.CalendarDate >= TaskManager.Start)
        AND ((TaskManagerQryAllOptions.CalendarDate <= TaskManager.Finish) 
                OR (TaskManager.Finish Is Null))
    ORDER BY TaskManagerQryAllOptions.CalendarDate;
    

    The final query is an INSERT. As we will be using this query frequently, we don’t want it to generate duplicates, so we need to filter out already created records.

    INSERT INTO Task ( TaskName, TaskDate )
    SELECT TaskManagerQrySelect.TaskName, TaskManagerQrySelect.CalendarDate
    FROM TaskManagerQrySelect
    WHERE Not Exists(
        SELECT *
        FROM Task
        WHERE Task.TaskName = TaskManagerQrySelect.TaskName
            AND Task.TaskDate = TaskManagerQrySelect.CalendarDate);
    

    One limitation of this method is that if the date of repetition (e.g. the 15th of each month) is changed, the future records with the wrong day will remain. A solution to this would be to update all the future records with the adjusted date, then run the insert.

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

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

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.