Print Page | Close Window

Get dates from recurrence pattern

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=14043
Printed Date: 06 October 2024 at 12:24pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Get dates from recurrence pattern
Posted By: DataFlowJoe
Subject: Get dates from recurrence pattern
Date Posted: 16 April 2009 at 2:13pm
Can anyone show me how to decipher the recurrence pattern table so I can work out an algorithm for enumerating all the dates.
Is there an example on this forum, I had a look but couldn't find anything. I'll be using VB.
 
Thanks in advance,
 
Joe


-------------
He is no fool who gives what he cannot keep to gain what he cannot lose. (Jim Elliott)



Replies:
Posted By: mdoubson
Date Posted: 16 April 2009 at 4:46pm
You can do it using existed ActiveX interface

-------------
Mark Doubson, Ph.D.


Posted By: DataFlowJoe
Date Posted: 16 April 2009 at 5:59pm
I'm using the microsoft access provider, are you able to give me an example of how I could achieve this using the ActiveX interface. I have found the help file has very few examples of how to work with the calendar ActiveX control.
 
Thanks in advance,
 
Joe


-------------
He is no fool who gives what he cannot keep to gain what he cannot lose. (Jim Elliott)


Posted By: DataFlowJoe
Date Posted: 17 April 2009 at 12:48pm
Can anyone provide me with a simple example for retrieving all events including recurring events between 2 dates. This must be quite simple, yet I've searched the forum and the help file but have not found anything suitable.
I'm not using a custom provider, just an Access connection string.
I'm happy to create an ADO connection if that is required.
My programming language is VB.
 
Please...please help, I'm desperate for this, I've spent at least 10 hrs fiddling around with this so far.
 
Thanks in advance.
 
Hopefully I'll be able to help this forum in the future.
 
Joe


-------------
He is no fool who gives what he cannot keep to gain what he cannot lose. (Jim Elliott)


Posted By: dentor
Date Posted: 19 April 2009 at 9:24am
Hello DataFlowJoe,
 
I think that the better way to retrieve all the events including recurring events is to use the RetrieveDayEvents method from the CalendarControl ActiveX that will do all the work.
 
Below a little code to quickly show one way to do the job:
 
' ---------- the definition of the events collection to be return (can be extented) 
Private Type MyEvents
    StartTime   As Date
    EndTime     As Date
    Subject As String
End Type
 
' ---------- The call of the subroutine
Private Sub FindEvents()
Dim FindEvents() As MyEvents, EvtCount As Long
Dim DateStart As Date, DateEnd As Date
Dim pEvent As CalendarEvent, i As Long
 
    ' *** Find events from now plus 6 days
    EvtCount = 0
    ReDim FindEvents(EvtCount)
    DateStart = Now
    DateEnd = DateAdd("d", 6, DateStart)
    ' *** the subroutine
    FindAllEvents DateStart, DateEnd, EvtCount, FindEvents()
    ' *** view the events
    For i = 1 To EvtCount
        Debug.Print FindEvents(i).StartTime & "-" & FindEvents(i).EndTime & "-" & FindEvents(i).Subject
    Next
End Sub
 
' ---------- The subroutine (the search for each day in the periode)
Private Sub FindAllEvents(DateStart As Date, DateEnd As Date, EvtCount As Long, FindEvents() As MyEvents)
Dim Events As CalendarEvents, Day As Date
Dim pEvent As CalendarEvent
 
    Day = DateStart
    Do
        Set Events = CalendarControl.DataProvider.RetrieveDayEvents(Day)
        For Each pEvent In Events
            EvtCount = EvtCount + 1
            ReDim Preserve FindEvents(EvtCount)
            FindEvents(EvtCount).StartTime = pEvent.StartTime
            FindEvents(EvtCount).EndTime = pEvent.EndTime
            FindEvents(EvtCount).Subject = pEvent.Subject
        Next
        Day = DateAdd("d", 1, Day)
    Loop Until Day > DateEnd
End Sub
 
 
I hope it can help you.
 


-------------
Product: Xtreme SuitePro (ActiveX) version 13.0.0
Platform: Windows XP (32bit) - SP 3
Language: Visual Basic 6.0 SP 6


Posted By: DataFlowJoe
Date Posted: 20 April 2009 at 1:40pm
Hi Dentor,
 
This is perfect....!! I've now got it working and doing what I hoped it could do.
 
Thank you so much for helping me out with this, I'm sure the calendar ActiveX would be an even better product for developers if there were more examples like the one you've posted for me.
 
The help file that comes with the control hardly has any examples for working with the scores of properties, methods and events.
Better documentation would get developers up to speed a lot quicker with it. 
The control itself is brilliant in what it does, so no complaints there.
 
Thanks again for taking the time to answer my question, hopefully it will benefit others.
 
Cheers from South Wales UK
 


-------------
He is no fool who gives what he cannot keep to gain what he cannot lose. (Jim Elliott)


Posted By: jgordon428
Date Posted: 12 April 2010 at 2:05pm
Has anyone figured out a way to do this in a SQL Server stored procedure? There are parts of our system that require the scheduling data to be in a recordset format (e.g. crystal reports, searching for available time slots, etc.). Having a stored procedure to handle the recurrence expansion rather than using the ActiveX control and then inserting records into a temporary table would be hugely helpful.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net