dynamic date array

I need to create a dynamic date array based on two date field and an interval number field.

For example,
I have date1 and date2 on doc
I have interval number field
on saving the document, I want my script to create an array of date ranges between date1 and date2 taking the interval value into consideration and save all those values to a field in a document

So if date1 is today and date2 is one year away and the interval is 30 days, the array should have the following dates:

31/07/2006
30/08/2006
and so on until the end which is 31/07/2007 is reached
Then save all those values to a multi value date field on the document.

Thank you in advance.

varvouraAsked:
Who is Participating?
 
madheeswarCommented:
May I know what code you are using?
Place your code here..
0
 
madheeswarCommented:
Dim fromdate As New notesdatetime(uidoc.fieldgettext("leavefromdate_d"))
      Dim todate As New notesdatetime(uidoc.fieldgettext("leavetodate_d"))
      m_range=""
      Do While Datevalue(fromdate.dateonly) <= Datevalue(todate.dateonly)
            m_range=m_range + fromdate.dateonly + ", "
            Call fromdate.adjustday(1) ' You can specify you interval number here.
'call fromdate.adjustday(uidoc.getfield("intervalnum"))
      Loop
      m_range = Left$(m_range,Len(m_range)-2)
      'Msgbox (m_range)
'Call uidoc.fieldsettext("leavelistdates_x",m_range)
      doc.leavelistdates_x=m_range


0
 
varvouraAuthor Commented:
This is given the "Not a member error"

Call fromdate.adjustday(uidoc.getfield("interval"))

I changed to getfieldtext and getfieldvalue, but none worked.
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
madheeswarCommented:
sorry..
 it is Call fromdate.adjustday(uidoc.fieldgettext("interval"))
0
 
varvouraAuthor Commented:
I fixed the error, but the dates are not populating in the field on the document
0
 
varvouraAuthor Commented:
nope, tried that and still not a member error, but what i've done is declared another variable to pick the value from the document, then call it in the adjust function and I have no syntax errors now but the field on document is blank instead of having the list of required dates
0
 
madheeswarCommented:
if possible try to debug and check if it doing correctly or not. Try to have some msg boxes..

like..
m_range = Left$(m_range,Len(m_range)-2)
    Msgbox (m_range)
0
 
Sjef BosmanGroupware ConsultantCommented:
Maddy, there's no need to use NotesDateTime objects.

    Dim d1 As Variant
    Dim d2 As Variant
    Dim interval As Integer
    Dim dates() As Variant
    Dim i As Integer
    Dim n As Integer

    d1= doc.Date1(0)
    d2= doc.Date2(0)
    interval= doc.Interval(0)
    d1= d1 + interval
    n= Cint((d2-d1)/interval
    If n>=0 Then
        Redim dates(n) As Variant
        i= 0
        Do While d1<=d2
            dates(i)= CDat(d1)
            i= i + 1
            d1= d1 + interval
        Loop
    Else
        Error 1001, "Period to small for chosen interval"
    End If
    doc.DateRange= dates
0
 
madheeswarCommented:
Looks simple Sjef.
Thanks for correcting me..
0
 
Sjef BosmanGroupware ConsultantCommented:
It's not correcting, it's just another view on the matter :)
0
 
Sjef BosmanGroupware ConsultantCommented:
Aaargh, terrible typo!!

        Error 1001, "Period too small for chosen interval"
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.