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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:52:06+00:00 2026-05-17T15:52:06+00:00

I’m working on a system to store appointments and recurring appointments. My schema looks

  • 0

I’m working on a system to store appointments and recurring appointments. My schema looks like this

Appointment
-----------
ID
Start
End
Title
RecurringType
RecurringEnd

RecurringTypes
---------------
Id
Name

I’ve keeped the Recurring Types simple and only support

Week Days,
Weekly,
4 Weekly,
52 Weekly

If RecurringType is null then that appointment does not recur, RecurringEnd is also nullable and if its null but RecurringType is a value then it will recur indefinatly. I’m trying to write a stored procedure to return all appointments and their dates for a given date range.

I’ve got the stored procedure working for non recurring meetings but am struggling to work out the best way to return the recurrences this is what I have so far

ALTER PROCEDURE GetAppointments
(
    @StartDate DATETIME,
    @EndDate DATETIME
)
AS

SELECT  
    appointment.id,
    appointment.title,
    appointment.recurringType,
    appointment.recurringEnd,
    appointment.start,
    appointment.[end]
FROM
    mrm_booking
WHERE
    (
        Start >= @StartDate AND
        [End] <= @EndDate
    ) 

I now need to add in the where clauses to also pick up the recurrences and alter what is returned in the select to return the Start and End Dates for normal meetings and the calculated start/end dates for the recurrences.

Any pointers on the best way to handle this would be great. I’m using SQL Server 2005

  • 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-17T15:52:06+00:00Added an answer on May 17, 2026 at 3:52 pm

    I ended up doing this by creating a temp table of everyday between the start and end date along with their respective day of the week. I limited the recurrence intervals to weekdays and a set amount of weeks and added where clauses like this

            --Check Week Days Reoccurrence
            (
                mrm_booking.repeat_type_id = 1 AND              
                #ValidWeeklyDayOfWeeks.dow IN (1,2,3,4,5)
            ) OR
            --Check Weekly Reoccurrence
            (
                mrm_booking.repeat_type_id = 2 AND
                DATEPART(WEEKDAY, mrm_booking.start_date) = #ValidWeeklyDayOfWeeks.dow
            ) OR
            --Check 4 Weekly Reoccurences
            (
                mrm_booking.repeat_type_id = 3 AND
                DATEDIFF(d,#ValidWeeklyDayOfWeeks.[Date],mrm_booking.start_date) % (7*4) = 0
            ) OR
            --Check 52 Weekly Reoccurences
            (
                mrm_booking.repeat_type_id = 4 AND
                DATEDIFF(d,#ValidWeeklyDayOfWeeks.[Date],mrm_booking.start_date) % (7*52) = 0
            )
    

    In case your interested I built up a table of the days between the start and end date using this

    INSERT INTO #ValidWeeklyDayOfWeeks
    --Get Valid Reoccurence Dates For Week Day Reoccurences
    SELECT
        DATEADD(d, offset - 1, @StartDate) AS [Date],
        DATEPART(WEEKDAY,DATEADD(d, offset - 1, @StartDate)) AS Dow
    FROM
        (
            SELECT ROW_NUMBER() OVER(ORDER BY s1.id) AS offset
            FROM syscolumns s1, syscolumns s2
        ) a WHERE offset <= DATEDIFF(d, @StartDate, DATEADD(d,1,@EndDate)) 
    

    Its not very elegant and probably very specific to my needs but it does the job I needed it to do.

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

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
Specifically, suppose I start with the string string =hello \'i am \' me And
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Does anyone know how can I replace this 2 symbol below from the string

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.