473,326 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

time sheet form with datediff function

107 100+
Hello,
I am now working on timesheet form users can input in time and out time.
I wanted to have a txtbox called hours for each day that would calculate the hours.
I have tried the datediff("h", me.txtboxIN, me.txtboxOUT) and "n"
I am able to get the hours or the minutes - but cannot show them both together.

I thought with the minutes there might be a way to divide and show hours and minutes.
If a person came in at 7:30 am and left at 11:00 am -textboxHOURS should reflect 3.50 hours.
any ideas
thank you
Jul 29 '08 #1
4 2573
missinglinq
3,532 Expert 2GB
Find the minutes then divide by 60:
Expand|Select|Wrap|Line Numbers
  1. datediff("n", me.txtboxIN, me.txtboxOUT)/60
To round to 2 decimals (I think)
Expand|Select|Wrap|Line Numbers
  1. Round(datediff("n", me.txtboxIN, me.txtboxOUT)/60,2)
Linq ;0)>
Jul 29 '08 #2
ADezii
8,834 Expert 8TB
It's too close to bedtime, and I'm probably making this more complicated than need be, but assuming a Text Box on your Form is named txtHours, the following code placed in the AfterUpdate() Event of txtBoxOUT will produce the difference in HOURS:MINUTES Format, namely:
Expand|Select|Wrap|Line Numbers
  1. IN             OUT                txtHours
  2. 7:15          11:00                 3:45
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtBoxOUT_AfterUpdate()
  2. Dim intDiffInMin As Integer
  3. Dim txtIN As TextBox
  4. Dim txtOUT As TextBox
  5. Dim intHrs As Integer
  6. Dim intMins As Integer
  7.  
  8. Set txtIN = Me![txtBoxIN]
  9. Set txtOUT = Me![txtBoxOUT]
  10.  
  11.   If Not IsNull(txtIN) And Not IsNull(txtOUT) Then
  12.     If IsDate(txtIN) And IsDate(txtOUT) Then
  13.       intDiffInMin = DateDiff("n", txtIN, txtOUT)
  14.       intHrs = Int((intDiffInMin / 60))
  15.       intMins = intDiffInMin - (intHrs * 60)
  16.         Me![txtHours] = CStr(intHrs) & ":" & Format$(intMins, "00")
  17.     End If
  18.   End If
  19. End Sub
Jul 29 '08 #3
buddyr
107 100+
thank you
missinglinq
I wasn't able to get yours working- but I think I've been trying too hard on this and may be I inputed syntax wrong
Adezi- I used your solution-IT WORKS
thank you both
Jul 29 '08 #4
shonyv
2
Try This

=DateDiff("n",field,field)\60 & ":" & Format(DateDiff("n",field,field) Mod 60,"00")

Shony
Jun 4 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
6
by: Michael Bulatovich | last post by:
I have a very simple db I use for keeping track of hours, tasks, projects, clients etc. It has a form that I use to enter data. Currently the form has a textbox for a field called "start time",...
6
by: Mark Reed | last post by:
Hi Guru's, I have created a database to monitor hours I have worked as our payroll department are so crap. I work nights most of the time but occasionally I have to work on days. Between the hours...
3
by: luscus | last post by:
Thanks for all the responses on my first question. Unfortunately the answers I was given were too complicated for my small brain , and neophite condition to understand. So if you could talk down to...
2
by: John | last post by:
Hi I am trying to calculate time difference in hours between two times. I am using the datediff function. The results are peculiar; ? DateDiff("h", "00:30", "6:30") returns 6, but ?...
10
by: Drum2001 | last post by:
I have designed a "Time Tracker Database"... Basically a Time Clock. I have report that calculates the number of regular hours worked per week. Currently I am running the following query: ...
19
by: DonLi2006 | last post by:
Hi, ddl & dml project varchar(10) start char(5) stop char(5) ------------------------- ----- ----- hey now 21:00 19:25 new test 20:25 20:30 t 10 ...
0
yasirmturk
by: yasirmturk | last post by:
Standard Date and Time Functions The essential date and time functions that every SQL Server database should have to ensure that you can easily manipulate dates and times without the need for any...
15
by: student4lifer | last post by:
Hello, I have 2 time fields dynamically generated in format "m/d/y H:m". Could someone show me a good function to calculate the time interval difference in minutes? I played with strtotime() but...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.