[AccessD] A2K: Time diff calcs

Mark A Matte markamatte at hotmail.com
Tue Sep 14 09:20:11 CDT 2004


Darren,

I use something similar for a re-measure tool...(its like a built in 
stopwatch)...anyway...I just take a datediff of seconds...and then put it 
through this little sub to split it into seconds and minutes(could be 
converted for hours also).  Please let me know if you have any questions.

Thanks,

Mark A. Matte

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


>From: "Darren DICK" <d.dick at uws.edu.au>
>Reply-To: Access Developers discussion and problem 
>solving<accessd at databaseadvisors.com>
>To: "AccessD List" <AccessD at databaseadvisors.com>
>Subject: [AccessD] A2K: Time diff calcs
>Date: Tue, 14 Sep 2004 22:24:45 +1000
>
>Hello all
>I want to calculate then insert into a table the duration of a users logon
>in HOURS and MINUTES
>In the logon table the default value for the logon field is Now() and is
>captured at...You guessed at logon. I then run a query that updates the
>Logoff field to Now() once the user answers YES to loggin off. The theory
>being there will be a difference even if it is only 5 or 10 seconds. Unless
>some clown plays with the clock after loggin on --- but forget all that 
>:-))
>
>Both logon and logoff fields data types in the Logon Table are General Date
>(01/01/2004 15:45:25PM)
>
>So a user logs on at say...14/09/2004 10:08:45 PM and then logs off at
>say...14/09/2004 10:10:55 PM
>
>The time logged on = 2 mins and 10 secs but how do I calculate that?
>
>I have udsed DateDiff but with no success...
>DateDiff("Short Time",[LogonTimeAndDate],Now())
>DateDiff("mm",[LogonTimeAndDate],Now())
>DateDiff("nn",[LogonTimeAndDate],Now()) etc etc
>
>Many thanks in advance
>
>Darren
>
>
>--
>_______________________________________________
>AccessD mailing list
>AccessD at databaseadvisors.com
>http://databaseadvisors.com/mailman/listinfo/accessd
>Website: http://www.databaseadvisors.com





More information about the AccessD mailing list