Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2002
    Posts
    16

    Unanswered: Recurring meeting on multiple days UGH!

    Ugh!

    I need to create some SQL that will generate all the dates for a recurring meeting on multiple days per week.

    For example:
    a meeting on Monday , Wednesday and Friday at 10:00 am - 10:30 am from December 1st 2004 to Feb 28th 2005.

    I'm not sure what to do here.

    Any Ideas?

    Regards
    Russ

  2. #2
    Join Date
    Nov 2004
    Posts
    6
    DECLARE @TheDate smalldatetime
    DECLARE @EndDate smalldatetime

    SET @TheDate = '2004-12-01'
    SET @EndDate = '2005-02-28'

    DECLARE @MeetingDates table
    (
    MeetingDateTime smalldatetime,
    Duration int
    )


    WHILE @TheDate <= @EndDate
    BEGIN
    IF DATEPART(dw, @TheDate) IN (2, 4, 6)
    BEGIN
    INSERT INTO @MeetingDates
    VALUES (@TheDate + '10:00', 30)
    END

    SET @TheDate = DATEADD(d, 1, @TheDate)
    END

    SELECT CASE DATEPART(dw, MeetingDateTime) WHEN 2 THEN 'Mon'
    WHEN 4 THEN 'Wed'
    WHEN 6 THEN 'Fri'
    ELSE 'Houston! We have a problem.'
    END AS MeetingDay,
    CONVERT(varchar(50), MeetingDateTime, 100) AS StartDateTime,
    Duration,
    CONVERT(varchar(50), DATEADD(mi, Duration, MeetingDateTime), 100) AS EndDateTime
    FROM @MeetingDates
    ORDER BY MeetingDateTime
    GO

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •