[AccessD] Recording Time

Jim Dettman jimdettman at earthlink.net
Fri Jun 2 10:46:39 CDT 2006


Larry,

<<Another approach would be to use two text boxes to collect hours and
minutes, then convert and store the data as minutes. (I could use a display
format to convert the minutes into something like: 4:15). >>

  You want to stay flexible.  The way I approached this was to make sure
that the presentation of the data was entirely separate from the storage
part.  No matter what format the client wants, I always store it the same
way.  

  As you already pointed out, something like 4.50; is that 4 hours 30
minutes or 4 hours and 50 minutes?  I've had clients ask for it both ways.
Then there are the ones that want 12 hour (am/pm) vs 24 hour format
(military).  So there are a few variations.

  Given all that, what I've done in the past is that I store:

  WorkDate - Date/Time - Stores a date only
  StartTime - Currency - HHMM
  StopTime - Currency - HHMM

  The HHMM is hours and actual minutes.

  In a form, I use four text boxes:

   Date
   Start time
   Stop time
   ET

   I always have them enter the time in a single control. Generally as a
three or four digit number and omit the decimal point.   Then I use the
function below to calculate ET based on the format.

   I used this setup for quite of few time clock/incentive systems over the
past 15 years or so and its held up pretty well.

HTH,
Jim.

Private Sub CalculateET()

    Dim dblStartTime As Double
    Dim dblStopTime As Double
    
    ' Use for minutes expressed as part of an hour
    ' i.e. start/stop time of 6.33 is 6 hours, 20 minutes
    'dblStartTime = TimeSerial(Fix(Me![txtStart]), Round((Me![txtStart] -
Fix(Me![txtStart])) * 60, 0), 0)
    'If IsNull(Me![txtStop]) Then
    '  dblStopTime = 0
    'Else
    '  dblStopTime = TimeSerial(Fix(Me![txtStop]), Round((Me![txtStop] -
Fix(Me![txtStop])) * 60, 0), 0)
    'End If
    
         
    ' Use for minutes expressed as minutes
    ' i.e. start/stop time of 6.33 is 6 hours, 33 minutes
    If IsNull(Me![txtStart]) Then
      dblStartTime = 0
    Else
      dblStartTime = TimeSerial(Fix(Me![txtStart] / 100), Me![txtStart] -
(Fix(Me![txtStart] / 100) * 100), 0)
    End If
  
    If IsNull(Me![txtStop]) Then
      dblStopTime = 0
    Else
      dblStopTime = TimeSerial(Fix(Me![txtStop] / 100), Me![txtStop] -
(Fix(Me![txtStop] / 100) * 100), 0)
    End If
         
    ' Since we only track the "start date", we need to add
    ' 24 hours to the stop time to indicate that the end
    ' time fell into another day.
    If dblStopTime <= dblStartTime Then dblStopTime = dblStopTime + 1
    
    ' Calculate ET.
    Me![txtET] = Round(DateDiff("n", dblStartTime, dblStopTime) / 60, 2)

End sub

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Lawrence Mrazek
Sent: Friday, June 02, 2006 10:48 AM
To: 'Access Developers discussion and problem solving'
Subject: [AccessD] Recording Time

 
Hi Folks:

I have an app that tracks time spent on various activities (production,
cleaning, etc.). 

I'd appreciate some opinions on the best ways to record the time spent.
Basically, we're looking at hours and minutes spent, usually something like
four hours, 15 minutes. I considered having the app record the time as: 4.25
(4 hrs 15 minutes), but this approach seems to confuse some of the users. 

Another approach would be to use two text boxes to collect hours and
minutes, then convert and store the data as minutes. (I could use a display
format to convert the minutes into something like: 4:15). 

Any ideas on best practices for storing this type of data?

Thanks in advance!

Larry Mrazek
LCM Research, Inc.
www.lcm-res.com
lmrazek at lcm-res.com
ph. 314.432.5886
fx. 314.432.3304


-- 
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