Domino Code Fragment

Code Name*
Determine the number of seconds, hours, minutes, days and weeks between now and a particular date?
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.117.111.1
Description*
The following sample script determines and displays the numbers of seconds, minutes, hours, days and weeks between now and both the start of the next year and the start of the current year. You can modify the script to compute the difference between the current date and any user-defined date.
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
IMPORTANT NOTE: In order for this example to perform as intended, the script must be laid out exactly as indicated.
Files/Graphics attachments (if applicable): Code:
Sample Script:

Sub Initialize
Dim secondsLeft As Long
Dim minutesLeft As Long
Dim hoursLeft As Double
Dim daysLeft As Integer
Dim weeksLeft As Integer
Dim secondsGone As Long
Dim minutesGone As Long
Dim hoursGone As Double
Dim daysGone As Integer
Dim weeksGone As Integer
Dim todayDateTime As NotesDateTime
Dim nextYearDateTime As NotesDateTime


Set todayDateTime = New NotesDateTime( Now)
Set nextYearDateTime = New NotesDateTime( "1/1/" & Year(Now)+1)
secondsLeft = nextYearDateTime.TimeDifference( todayDateTime )
minutesLeft = secondsLeft/60
hoursLeft = Round(minutesLeft/60,0)
daysLeft = hoursLeft/24
weeksLeft = daysLeft/7


printString = "There are " & secondsLeft & " seconds, " & minutesLeft & " minutes, " & hoursLeft
& " hours, " _
& daysLeft & " days, and " & weeksLeft & " weeks left until the end of the year"
Messagebox printstring


Set nextYearDateTime = New NotesDateTime( "1/1/" & Year(Now))
secondsGone = todayDateTime.TimeDifference( nextYearDateTime )
minutesGone = secondsGone/60
hoursGone = Round(minutesGone/60,0)
daysGone = hoursGone/24
weeksGone = daysGone/7


printString = "There have been " & secondsGone & " seconds, " & minutesGone & " minutes, " &
hoursGone & " hours, " _
& daysGone & " days, and " & weeksGone & " weeks since the start of the year"
Messagebox printstring
End Sub