To find the number of seconds, minutes, hours, days, weeks between the two selected dates in lotus script.
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim varDate1 As NotesItem
Dim varDate2 As NotesItem
Dim dt1 As NotesDateTime
Dim dt2 As NotesDateTime
Dim dt3 As New NotesDateTime("")
Dim dt4 As New NotesDateTime("")
Dim diffSeconds As Long
Dim minutesLeft As Long
Dim hoursLeft As Double
Dim daysLeft As Integer
Dim weeksLeft As Integer
Dim monthLeft As Integer
Dim remDays As Integer
Dim mNames As Variant
Dim currMonth As String
Dim lastMonth As String
Set uidoc = workspace.CurrentDocument
Set varDate1 = uidoc.Document.GetFirstItem("txDate1")
Set dt1 = varDate1.DateTimeValue
Set varDate2 = uidoc.Document.GetFirstItem("txDate2")
Set dt2 = varDate2.DateTimeValue
dt3.LocalTime = Datenumber(Year(dt1.LocalTime), Month(dt1.LocalTime), 1)
Call dt3.AdjustMonth(1)
Call dt3.AdjustDay(-1)
dt4.LocalTime = Datenumber(Year(dt2.LocalTime), Month(dt2.LocalTime), 1)
Call dt4.AdjustMonth(1)
Call dt4.AdjustDay(-1)
currMonth = dt4.LocalTime
'Msgbox currMonth,,"currMonth"
diffSeconds = dt2.TimeDifference(dt1)
minutesLeft = diffSeconds/60
hoursLeft = Round(minutesLeft/60,0)
daysLeft = hoursLeft/24
weeksLeft = daysLeft/7
monthLeft = daysLeft/30.4
Msgbox diffSeconds
printString = "There are " & secondsLeft & " seconds, " & minutesLeft & " minutes, " & hoursLeft & " hours, " _
& daysLeft & " days, and " & weeksLeft & " weeks left until the end of the year"
Messagebox printstring
Dim uidoc As NotesUIDocument
Dim varDate1 As NotesItem
Dim varDate2 As NotesItem
Dim dt1 As NotesDateTime
Dim dt2 As NotesDateTime
Dim dt3 As New NotesDateTime("")
Dim dt4 As New NotesDateTime("")
Dim diffSeconds As Long
Dim minutesLeft As Long
Dim hoursLeft As Double
Dim daysLeft As Integer
Dim weeksLeft As Integer
Dim monthLeft As Integer
Dim remDays As Integer
Dim mNames As Variant
Dim currMonth As String
Dim lastMonth As String
Set uidoc = workspace.CurrentDocument
Set varDate1 = uidoc.Document.GetFirstItem("txDate1")
Set dt1 = varDate1.DateTimeValue
Set varDate2 = uidoc.Document.GetFirstItem("txDate2")
Set dt2 = varDate2.DateTimeValue
dt3.LocalTime = Datenumber(Year(dt1.LocalTime), Month(dt1.LocalTime), 1)
Call dt3.AdjustMonth(1)
Call dt3.AdjustDay(-1)
dt4.LocalTime = Datenumber(Year(dt2.LocalTime), Month(dt2.LocalTime), 1)
Call dt4.AdjustMonth(1)
Call dt4.AdjustDay(-1)
currMonth = dt4.LocalTime
'Msgbox currMonth,,"currMonth"
diffSeconds = dt2.TimeDifference(dt1)
minutesLeft = diffSeconds/60
hoursLeft = Round(minutesLeft/60,0)
daysLeft = hoursLeft/24
weeksLeft = daysLeft/7
monthLeft = daysLeft/30.4
Msgbox diffSeconds
printString = "There are " & secondsLeft & " seconds, " & minutesLeft & " minutes, " & hoursLeft & " hours, " _
& daysLeft & " days, and " & weeksLeft & " weeks left until the end of the year"
Messagebox printstring
Comments
Post a Comment