Solved

Form time to number

Posted on 2002-06-04
3
199 Views
Last Modified: 2006-11-17
Hello,

My question is how to convert a time value into a number
so 8:40 into 8,6667

0
Comment
Question by:LBH
3 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 7053502
try this:

cdbl(datepart("n", yourfield)) + 60/cdbl(datepart("s", yourfield))

CHeers
0
 
LVL 44

Accepted Solution

by:
Arthur_Wood earned 50 total points
ID: 7053535
even easier:

Dim MyTime as Double

MyTime = CDbl(#8:40#) * 24

whcih you display the value of MyTime, it will show 8.6666667

The trick is to realize that a Date (or Time) is stored internally as a DOUBLE precision Decimal value, with the Decimal part being the fraction of 1 24-hour day.

So convert the Time value to a Double, and then Multiply by 24 to get hours and fractions of an hour.

Arthur Wood
0
 

Author Comment

by:LBH
ID: 7055790
If i apply the suggestion of angellll is get the #error? value.

And where do i have to apply the suggestion of Arthur Wood, create a new module ? The (#8:40#) do i have to replace that with the field name where the time is stored ?

I hope anyone can help me !
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now