?
Solved

dynamic date array

Posted on 2006-05-29
11
Medium Priority
?
272 Views
Last Modified: 2013-12-18
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.

0
Comment
Question by:varvoura
  • 5
  • 3
  • 3
11 Comments
 
LVL 19

Expert Comment

by:madheeswar
ID: 16783409
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
 

Author Comment

by:varvoura
ID: 16783467
This is given the "Not a member error"

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

I changed to getfieldtext and getfieldvalue, but none worked.
0
 
LVL 19

Expert Comment

by:madheeswar
ID: 16783475
sorry..
 it is Call fromdate.adjustday(uidoc.fieldgettext("interval"))
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:varvoura
ID: 16783487
I fixed the error, but the dates are not populating in the field on the document
0
 
LVL 19

Accepted Solution

by:
madheeswar earned 1000 total points
ID: 16783492
May I know what code you are using?
Place your code here..
0
 

Author Comment

by:varvoura
ID: 16783495
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
 
LVL 19

Expert Comment

by:madheeswar
ID: 16783501
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
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16783559
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
 
LVL 19

Expert Comment

by:madheeswar
ID: 16783574
Looks simple Sjef.
Thanks for correcting me..
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16783584
It's not correcting, it's just another view on the matter :)
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 16783589
Aaargh, terrible typo!!

        Error 1001, "Period too small for chosen interval"
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is an old article, please see an updated version of this article, located here: http://www.experts-exchange.com/articles/23619/Notes-8-5x-Windows-7-Notes-info-and-tips.html
Problem "Can you help me recover my changes?  I double-clicked the attachment, made changes, and then hit Save before closing it.  But when I try to re-open it, my changes are missing!"    Solution This solution opens the Outlook Secure Temp Fold…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month13 days, 15 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question