Solved

Form time to number

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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
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 …

810 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