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
4 2573
Find the minutes then divide by 60: - datediff("n", me.txtboxIN, me.txtboxOUT)/60
To round to 2 decimals (I think) - Round(datediff("n", me.txtboxIN, me.txtboxOUT)/60,2)
Linq ;0)>
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: - IN OUT txtHours
-
7:15 11:00 3:45
- Private Sub txtBoxOUT_AfterUpdate()
-
Dim intDiffInMin As Integer
-
Dim txtIN As TextBox
-
Dim txtOUT As TextBox
-
Dim intHrs As Integer
-
Dim intMins As Integer
-
-
Set txtIN = Me![txtBoxIN]
-
Set txtOUT = Me![txtBoxOUT]
-
-
If Not IsNull(txtIN) And Not IsNull(txtOUT) Then
-
If IsDate(txtIN) And IsDate(txtOUT) Then
-
intDiffInMin = DateDiff("n", txtIN, txtOUT)
-
intHrs = Int((intDiffInMin / 60))
-
intMins = intDiffInMin - (intHrs * 60)
-
Me![txtHours] = CStr(intHrs) & ":" & Format$(intMins, "00")
-
End If
-
End If
-
End Sub
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
Try This
=DateDiff("n",field,field)\60 & ":" & Format(DateDiff("n",field,field) Mod 60,"00")
Shony
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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",...
|
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...
|
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...
|
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
?...
|
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:
...
|
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 ...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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
|
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...
|
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...
| |