473,406 Members | 2,843 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,406 software developers and data experts.

Calculation of time

Hi all

I am trying to calculate the two different time field. When I entered
in field like 7:00 and 15:00 the result is 8 hrs but when I entered
15:30 the result is also 8 hrs. I am using the following VBA code

Private Sub TimeToDay_AfterUpdate()

'Me.TotDay = (DateDiff("n", Me.TimeFromDay, Me.TimeToDay) - 30) / 60

End Sub

Please help me to solve this problem.

Thanks in advance.

Naushad
Feb 18 '08 #1
4 1423
You'll need to format your [TotDay] control to display at least 1 decimal
place to see fractions of an hour, i.e. 1.45 hours. If you want to display
your time result as hrs:min, then you'll need to roll-your-own format.
-Ed
<nh*****@kockw.comwrote in message
news:09**********************************@q70g2000 hsb.googlegroups.com...
Hi all

I am trying to calculate the two different time field. When I entered
in field like 7:00 and 15:00 the result is 8 hrs but when I entered
15:30 the result is also 8 hrs. I am using the following VBA code

Private Sub TimeToDay_AfterUpdate()

'Me.TotDay = (DateDiff("n", Me.TimeFromDay, Me.TimeToDay) - 30) / 60

End Sub

Please help me to solve this problem.

Thanks in advance.

Naushad

Feb 18 '08 #2
Ed Robichaud wrote:
You'll need to format your [TotDay] control to display at least 1 decimal
place to see fractions of an hour, i.e. 1.45 hours. If you want to display
your time result as hrs:min, then you'll need to roll-your-own format.
-Ed
Expanding on what you wrote...
ts = #7:00#
te = #15:30#
? timeserial(0,datediff("n",ts,te),0)
8:30:00 AM
? Format(timeserial(0,datediff("n",ts,te),0),"h.n")
8.30

The number to the right of the decimal point is in minutes, not a
decimal equivalent.

Creeps
http://www.youtube.com/watch?v=aUgTCpLJOEU&NR=1
>
<nh*****@kockw.comwrote in message
news:09**********************************@q70g2000 hsb.googlegroups.com...
>>Hi all

I am trying to calculate the two different time field. When I entered
in field like 7:00 and 15:00 the result is 8 hrs but when I entered
15:30 the result is also 8 hrs. I am using the following VBA code

Private Sub TimeToDay_AfterUpdate()

'Me.TotDay = (DateDiff("n", Me.TimeFromDay, Me.TimeToDay) - 30) / 60

End Sub

Please help me to solve this problem.

Thanks in advance.

Naushad


Feb 18 '08 #3
On Feb 18, 8:09*pm, Salad <o...@vinegar.comwrote:
Ed Robichaud wrote:
You'll need to format your [TotDay] control to display at least 1 decimal
place to see fractions of an hour, i.e. 1.45 hours. * If you want to display
your time result as hrs:min, then you'll need to roll-your-own format.
-Ed

Expanding on what you wrote...
ts = #7:00#
te = #15:30#
? timeserial(0,datediff("n",ts,te),0)
8:30:00 AM
? Format(timeserial(0,datediff("n",ts,te),0),"h.n")
8.30

The number to the right of the decimal point is in minutes, not a
decimal equivalent.

Creepshttp://www.youtube.com/watch?v=aUgTCpLJOEU&NR=1


<nhai...@kockw.comwrote in message
news:09**********************************@q70g2000 hsb.googlegroups.com...
>Hi all
>I am trying to calculate the two different time field. When I entered
in field like 7:00 and 15:00 the result is 8 hrs but when I entered
15:30 the result is also 8 hrs. I am using the following VBA code
>Private Sub TimeToDay_AfterUpdate()
>'Me.TotDay = (DateDiff("n", Me.TimeFromDay, Me.TimeToDay) - 30) / 60
>End Sub
>Please help me to solve this problem.
>Thanks in advance.
>Naushad- Hide quoted text -

- Show quoted text -
Hi Creep

I did [TotDay] control to display at least 1 decimal place to see
fractions of an hour and expanded my code as per your suggestion but
the result is same i.e. the whole no. not fraction.

Please help me to solve this problem.

Naushad
Feb 21 '08 #4
On Wed, 20 Feb 2008 22:44:32 -0800 (PST), nh*****@kockw.com wrote:
>>
<nhai...@kockw.comwrote in message
news:09**********************************@q70g200 0hsb.googlegroups.com...
>>Hi all
>>I am trying to calculate the two different time field. When I entered
in field like 7:00 and 15:00 the result is 8 hrs but when I entered
15:30 the result is also 8 hrs. I am using the following VBA code
>>Private Sub TimeToDay_AfterUpdate()
>>'Me.TotDay = (DateDiff("n", Me.TimeFromDay, Me.TimeToDay) - 30) / 60
>>End Sub
>>Please help me to solve this problem.
>>Thanks in advance.
>>Naushad- Hide quoted text -

- Show quoted text -

Hi Creep

I did [TotDay] control to display at least 1 decimal place to see
fractions of an hour and expanded my code as per your suggestion but
the result is same i.e. the whole no. not fraction.

Please help me to solve this problem.

Naushad
Is the TotDay control bound to a field? Possibly an integer field?

Perhaps you should look at the formatting of your control again.

?(datediff("n",#7:00#,#15:00#)-30)/60
7.5

What's with that "- 30"? It looks as though someone might be
intending some sort of rounding.
Feb 21 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: maceo | last post by:
I have some code that extracts the data from a table and performs a calculation (total time) on one of the columns. Here is the code: <?php /* Database connection */
2
by: rodger | last post by:
hi all, I have a form with two text boxes, a go button and a formula in the code to perform a calculation a value is entered in one text box, and press buttonm a result is computed which is...
2
by: Del | last post by:
Thanks in advance for any help. I have a database that was created in Access 2000. Several users have been upgraded to Access 2003. Since upgrading to 2003 we have noticed that some of the...
4
by: Michiel Alsters | last post by:
Hello everybody, I hope anybody can help me. I'll try to give a brief overview of my problem. I have running a program that performs a heavy calculation. To give the user feedback what the...
5
by: rogerzar | last post by:
Hi all In my application I am displaying bipmap image I am using the log10() function, but it takes very long time to display the image, the pixel array size is 1272x1003 pixels. I am...
4
by: vg-mail | last post by:
Hello all, I have identical design for form and report but I am getting calculation error on form and everything is OK on report. The form and report are build up on SQL statement. The...
10
by: 60325 | last post by:
This is the page where I collect the data in drop-down boxes with values of 1-10 and send it to a submitted page to do calculations. Example: Employee1 TeamScore(1-10) Employee2 ...
19
by: LucasLondon | last post by:
Hi there, First of all apologies for the long post. Hope someone can offer some advice. I have about 200 columns of time series data that I need to perform a correlation analysis on in terms...
3
by: mattmao | last post by:
Okay, I was asked by a friend about the result of this limit: http://bbs.newwise.com/attdata/forumid_14/20070922_fe7f77c81050413a20fbDWYOGm7zeRj3.jpg Not n->zero but n-> + infinite I really...
2
by: John Torres | last post by:
I created a form with “Time In1”, “Time Out1”, “Time In2”, “Time Out2”. I’m able to calculate the time correctly when it was during the day shifts from 7:00 AM (Time In1) 5:00 PM (Time Out1) = 10:00...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.