Results 1 to 2 of 2

Thread: Calculate Time

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

    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,418
    Provided Answers: 7
    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 06:12. Reason: spelling
    hope this help

    See clear as mud


    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 based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

Posting Permissions

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