This function adjusts the specified time-date value by the number of years, months, days, hours, minutes, and/or seconds you specify. The amount of adjustment may be positive or negative. This function is the equivalent of @Adjust in formula language. I hope someone finds this function useful.

Function Adjust(pDateToAdjust As NotesDateTime, pYear As Integer, pMonth As Integer, pDay As Integer, pHour As Integer, pMinute As Integer, pSecond As Integer) As NotesDateTime

``` ' By Tony Murphy ' No Warranty Is Granted ' Use At Your Own Risk ' Purpose: ' This function adjusts the specified time-date value by the number of ' years, months, days, hours, minutes, and/or seconds you specify. ' The amount of adjustment may be positive or negative. ' Arguments: ' pDateToAdjust - Time-date. The time-date value you want to increment.
This should be a single value, not a range. ' pYear - Number. The number of years to increment by. ' pMonth - Number. The number of months to increment by. ' pDay - Number. The number of days to increment by. ' pHour - Number. The number of hours to increment by. ' pMinute - Number. The number of minutes to increment by. ' pSecond - Number. The number of seconds to increment by. ' Special Notes: ' None ' History: ' 06/08/01, Tony Murphy, Created. 'Example: ' Dim dateTime As New NotesDateTime( "" ) ' Call dateTime.SetNow ' Set dateTime = Adjust(dateTime, 0, 0, 3, 0, 0, 0) On Error Goto ErrorHandler Dim dateTime As NotesDateTime Set dateTime = pDateToAdjust Call dateTime.AdjustYear( pYear ) Call dateTime.AdjustMonth( pMonth ) Call dateTime.AdjustDay( pDay ) Call dateTime.AdjustHour( pHour ) Call dateTime.AdjustMinute( pMinute ) Call dateTime.AdjustSecond( pSecond ) Set Adjust = dateTime TheEnd: Exit Function ErrorHandler: Print "Adjust: " & Str\$(Err) & " at line " & Str\$(Erl) & ": " & Error\$ Resume TheEnd End Function
```

#### More News and Tutorials

This was first published in June 2001

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.