Results 1 to 2 of 2

Thread: Calculate Time

  1. #1
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,792

    Unanswered: Calculate Time

    Hi all I have a database that has Access 2007 in the front end and SQL Server 2005 as the engine. On one of the forms the users enters the time a participant has a session and the time they leave so [beginning time] and [end time] then [earned hours]. What I would like to do is just have the users enter the time they came in and then have the total hours pop up on the [earned hours] field. this is what I have for the birthday field
    Code:
    =DateDiff("yyyy",[StudentDateofBirth],Date())+(Date()<DateSerial(Year(Date()),Month([StudentDateofBirth]),Day([StudentDateofBirth])))

  2. #2
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,472
    Provided Answers: 10
    I would just store the [start time] [endtime] and [Minslaps] but would display the Hours:mins

    only because hours is a mod 60

    ie 50mins + 50mins = 100mins or 1:40

    here some code I use to convert mins to hours

    Code:
    Function MintoHrs(num)
    If num < 60 Then
    MintoHrs = "00:" & Format(num, "00")
    Else
    hh = Int(num / 60)
    Temp = (hh * 60)
    MintoHrs = Format(hh, "00") & ":" & Format((num - Temp), "00")
    End If
    End Function
    why store the [Minslaps] month end reporting will be easyer to work out

    =MintoHrs(Sum([Minslaps])) sumed and format in one step

    only problem is some total will look like 1988:43 my company hasn't ask to convert that to days:hours:min YET waiting (have done it)
    other little problem is the Sum([Minslaps]) gets very big number

    it work in Query as well
    Last edited by myle; 02-08-11 at 05:12. Reason: spelling
    hope this help

    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.
    DONT WORRY ABOUT THOSE WHO TALK BEHIND YOUR BACK
    THEY'RE BEHIND YOU FOR A REASON

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •