Wim Schimmel
10-Feb-2016, 02:54 PM
Hi,
I will substract some minutes from a datetime (worktime minus lunch)
If my time is 16:15 and subtract 75 minuten, dateaddminute calculate 14:00 and not 15:00
If subtract 74 minutes or if my current time is 16:16 the calculate is correct
I add one codeline //wss
Wim
9760
9761
Function DateAddMinuteWSS Global DateTime dtVar Integer iAdd Returns DateTime
DateTime dtVar2
Integer iCrnt iOverflow
If (IsNullDateTime(dtVar) or not(IsDateValid(dtVar))) Begin
Error DFERR_INVALID_DATETIME
Function_Return dtVar2
End
Move (DateGetMinute(dtVar)) to iCrnt
Move (iCrnt + iAdd) to iAdd
Move (ModAlt(iAdd,60)) to iCrnt
Move (DateSetMinute(dtVar,iCrnt)) to dtVar2
Move (iAdd/60 + If(iAdd<0,-1,0)) to iOverflow
If (iCrnt = 0 and iAdd < 0) Add 1 to iOverflow // wss
If (iOverflow) Begin
Move (DateAddHour(dtVar2,iOverflow)) to dtVar2
End
Function_Return dtVar2
End_Function
I will substract some minutes from a datetime (worktime minus lunch)
If my time is 16:15 and subtract 75 minuten, dateaddminute calculate 14:00 and not 15:00
If subtract 74 minutes or if my current time is 16:16 the calculate is correct
I add one codeline //wss
Wim
9760
9761
Function DateAddMinuteWSS Global DateTime dtVar Integer iAdd Returns DateTime
DateTime dtVar2
Integer iCrnt iOverflow
If (IsNullDateTime(dtVar) or not(IsDateValid(dtVar))) Begin
Error DFERR_INVALID_DATETIME
Function_Return dtVar2
End
Move (DateGetMinute(dtVar)) to iCrnt
Move (iCrnt + iAdd) to iAdd
Move (ModAlt(iAdd,60)) to iCrnt
Move (DateSetMinute(dtVar,iCrnt)) to dtVar2
Move (iAdd/60 + If(iAdd<0,-1,0)) to iOverflow
If (iCrnt = 0 and iAdd < 0) Add 1 to iOverflow // wss
If (iOverflow) Begin
Move (DateAddHour(dtVar2,iOverflow)) to dtVar2
End
Function_Return dtVar2
End_Function