Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

Form time to number

Posted on 2002-06-04
Medium Priority
208 Views
Hello,

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

0
Question by:LBH
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 143

Expert Comment

ID: 7053502
try this:

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

CHeers
0

LVL 44

Accepted Solution

Arthur_Wood earned 200 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

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month4 days, 9 hours left to enroll