MX Calendar Forum :: a fix for monthly recurring events

This thread was displayed: 252 times


Starting with 17th May 2007, Adobe Systems will stop offering support for any version of the discontinued InterAKT products. As a result, we will not answer to new support incidents starting with May 17th, 2007. Pending support incidents will still be followed in order to be closed. The product forums will remain open and be transformed in user-to-user forums. The general forums will be made read-only and not allow new posts or comments.

For more information about the affected products visit: www.interaktonline.com/Support/

View Threaded Show descending
Curtis Mulder
10-26-2006 22:20:18 GMT +2

I've seen multiple threads asking if there was a way for monthly recurring events to occur based on the weekday and not the date. For example, instead of an event recurring on Sep 1, Oct 1, Nov 1, etc... it would occur on the first Monday of every month. Well - I just figured out a way to make it work for ASP people. In the CAL_ViewBase.class.asp page, find the following code.

      Case "MONTH"
       tmpDate = CAL_extract("Y-m", thisStartDate) & "-" & CAL_extract("01 H:i:s", startDate)
       c_Date = CAL_addDate(tmpDate, CAL_extract("d", startDate)-1, "d")
       arrDates = array()
       Do While strcomp(c_Date, end_p) <= 0
        If strcomp(c_Date, startDate) >=0 And strcomp(c_Date, thisStartDate) >= 0 And CAL_extract("d", c_Date) = CAL_extract("d", startDate) Then
         arrDates = KT_array_push(arrDates, c_Date)
        End If
        tmpDate = CAL_addDate(tmpDate, 1, "m")
        c_Date = CAL_addDate(tmpDate, CAL_extract("d", startDate)-1, "d")
       Loop
       
       ' Create events array;
       For indx = 0 to UBound(arrDates)
        tmp_sdate = arrDates(indx)
        c_Date = CAL_extract("Y-m-d", tmp_sdate) & " 00:00:00"
           tmp_edate = CAL_addDate(c_Date, 60 * tmp_hour + tmp_minute, "i")
        If strcomp(tmp_edate, tmp_sdate) <= 0 Then
         tmp_edate = CAL_addDate(tmp_sdate, 1, "H")
                                End If

                                Set tmp_arr = Server.CreateObject("Scripting.Dictionary")
        tmp_arr("start") = tmp_sdate
        tmp_arr("end") = tmp_edate        
        tmp_arr("title") = title
        tmp_arr("desc") = description
        tmp_arr("link") = link
        tmp_arr("class") = specificClass
         
        If calendar.typeProp = "view" Then
         tmp_arr("link") = KT_addReplaceParam(page, calendar.getDateParam(), KT_convertDate(c_Date, "yyyy-mm-dd HH:ii:ss", KT_db_date_format))
        End If
        If Not data("body").Exists(c_Date) Then
         Set data("body")(c_Date) = Server.CreateObject("Scripting.Dictionary")
        End If
      &n

View full message
Back | Reply | Quote | Top
Ionut MOICIANU
10-27-2006 12:06:31 GMT +2

Hi Curtis,

Thank you for sharing the solution here, the logic is good.

Unfortunately, seems that KTML broken the code you pasted - like this code:

        nDate2 = Month(c_Date) & "/1/" & Year(c_Date)
        nM />          nDate3 = nDate2

So you could attach the code in a .txt file.

Regards,
Ionut

Reply | Quote | Top
Curtis Mulder
10-27-2006 16:27:31 GMT +2

Yes. Attached is a text file of the solution.

Reply | Quote | Top
Curtis Mulder
10-27-2006 16:30:04 GMT +2

Here is another adaption of the code that allows for events to occur on the 1st and 3rd OR on the 2nd and 4th weekday of a month. This may not be as useful for some people, but it is very helpful for our calendar needs. This creates a new C ASE called "MONTH2" - and so, you will need to add this option in your events INSERT/UPDATE forms.

Enjoy.

Reply | Quote | Top
Curtis Mulder
10-27-2006 16:32:09 GMT +2

NOTE: if using the 1st and 3rd / 2nd and 4th code option, the start date must be less than the 15th of a month for the code to work properly. If the start date is the 15th or higher, that date is actually the 3rd or 4th of a month and it messes up the math. Make sense?

Reply | Quote | Top
Ionut MOICIANU
10-27-2006 18:45:29 GMT +2

OK, thank you for your feedback. I'll share the ASP solution to anyone interested.

Ionut

Reply | Quote | Top
Samuel Waters
03-17-2008 16:24:40 GMT +2

Can you email me the correct text file that was created to allow for reoccuring monthly events to go by the day of the week verses date. Thanks

Reply | Quote | Top
© Adobe Systems Romania. All rights reserved.