[AccessD] Formatting time - minutes to hour:minutes

Gustav Brock gustav at cactus.dk
Fri Jan 9 04:11:25 CST 2004


Hi Mark

Are you aware that you can replace your creative counting loop with a
boring division ..?

/gustav


> I wrote the following to calculate Minutes and Seconds...with a few
> changes...you could use it to calculate Hours and Minutes.  I first 
> calculate the SECONDS...then use a loop that increments a count by 
> 1...multiply the counter by 60 and check againts SECONDS...when the 
> Counter*60 is greater than SECONDS...Counter-1 = MINUTES and 
> SECONDS-((counter-1)*60)=LeftOverSECONDS

> Hope it helps...

> Mark A. Matte

> Private Sub cmdStop_Click()
> Me!EndDTTM = Now()
> Dim Seconds
> Dim RMmin
> Dim RMsec
> Seconds = DateDiff("s", Me!StartDTTM, Me!EndDTTM)
> Dim Check, Counter
> Check = True: Counter = 0

> Do
>     Counter = Counter + 1
>     If Counter * 60 > Seconds Then
>         RMmin = Counter - 1
>         RMsec = Seconds - ((Counter - 1) * 60)
>         Check = False
>         Exit Do
>     End If
> Loop Until Check = False
> Forms!frmRecords!RMCallLengthM.Value = RMmin
> Forms!frmRecords!RMCallLengthS.Value = RMsec
> DoCmd.close
> End Sub



More information about the AccessD mailing list