Solved

Form time to number

Posted on 2002-06-04
3
204 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 143

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

820 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