How to Calculate Dates (weeks)?

How do i calculate the difference between 2 dates and convert them to weeks? thx in advance!

Subject: How to Calculate Dates (weeks)?

If you are using LotusScript, you can use the timeDifference method and then divide it into it’s component parts.

e.g.

Set date1 = New NotesDateTime ( “02/06/2008” )

Set date2 = New NotesDateTime ( “10/06/2008” )

lngDiff = date2.TimeDifference ( date1 )

nCalcMinutes = 60

nCalcHours = nCalcMinutes * 60

nCalcDays = nCalcHours * 24

nCalcWeeks = nCalcDays * 7

nRemainder = lngDiff

’ Work out the weeks

nWeeks = Int ( nRemainder / nCalcWeeks )

nRemainder = nRemainder - ( nWeeks * nCalcWeeks )

’ Work out the days

nDays = Int ( nRemainder / nCalcDays )

nRemainder = nRemainder - ( nDays * nCalcDays )

’ Work out the hours

nHours = Int ( nRemainder / nCalcHours )

nRemainder = nRemainder - ( nHours * nCalcHours )

’ Work out the minutes

nMinutes = Int ( nRemainder / nCalcMinutes )

nRemainder = nRemainder - ( nMinutes * nCalcMinutes )

nSeconds = nRemainder

Msgbox “Difference is " & nWeeks & " week(s) " & nDays & " day(s) " & nHours & " hour(s) " & nMinutes & " minute(s) " & nSeconds & " second(s)”

HTH