473,320 Members | 1,861 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,320 software developers and data experts.

Converting Decimal Time to Regular Time

Hello,


I need a format function for a query that will Convert: Decimal Time to Regular Time.

For Example my Database stores 8 Hours and 15 Min as: 8.25000008940697

And now I need a function to bring it back to: 8.15

Any help is greatly appreciated.
Oct 31 '07 #1
11 12514
missinglinq
3,532 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. Hours = int(OriginalTime)    
  2.  
  3. Minutes = int((OriginalTime-int(OriginalTime))*60)
  4.  
  5. NewTime = Hours & "." & Minutes
or in a calculated field in the Query Grid

Expand|Select|Wrap|Line Numbers
  1. NewTime: int(OriginalTime) & "." & int((OriginalTime-int(OriginalTime))*60)
Welcome to TheScripts!

Linq ;0)>
Oct 31 '07 #2
Wow, pretty good.

Now, I need to sum this feild and I'm having issues with that.

When I keep it the feild a NUMBER format is cuts off the minuites and if I keep the feild a TEXT feild I can't do a SUM Total.

Thanks Again.
Oct 31 '07 #3
I think I found my issue, But I can't see to solve it:

My Database records it as :6.08333333954215

Which is: 6 Hours and 5 Minuites

When I run the function you gave me it returns:

6.5

When we really need it to return 6.05


Thanks!!
Oct 31 '07 #4
ADezii
8,834 Expert 8TB
I think I found my issue, But I can't see to solve it:

My Database records it as :6.08333333954215

Which is: 6 Hours and 5 Minuites

When I run the function you gave me it returns:

6.5

When we really need it to return 6.05


Thanks!!
Following Linq's logic:
Expand|Select|Wrap|Line Numbers
  1. ? Format(int(6.08333333954215) & "." & int((6.08333333954215-int(6.08333333954215))*60), "hh:mm" returns 06:05
Oct 31 '07 #5
missinglinq
3,532 Expert 2GB
Thanks for the assist, ADezii! I was in a hurry and only tested against the data provided! I apologize!

Linq ;0)>
Nov 1 '07 #6
ADezii
8,834 Expert 8TB
Thanks for the assist, ADezii! I was in a hurry and only tested against the data provided! I apologize!

Linq ;0)>
Anytime Linq, just didn't want you to think that I was stepping on your toes (LOL).
Nov 1 '07 #7
Thanks, I guess the issue I'm having is:

I can't seem seem to Total the results, I tried a query and I also tried doing a Sum in the report. I get an error message in ACCESS that the query is too Complex.

Here is what I'm doing:

Value of Feild: 8.15000009536743
When I run the Query I get 8:09 (which is good)

But when I try to run a query to TOTAL the results--I get the Error Message.

I tried dumping the info to a table, but if I set it to TEXT I can't TOTAL it.. and if I set it to number I loose the values

Please Help.
Thanks
Nov 1 '07 #8
missinglinq
3,532 Expert 2GB
I think what you need to do is to run you total against the original field (your "decimal" times) and then plug the results into the formula above to get your total in hours and minutes.

Linq ;0)>
Nov 1 '07 #9
Thanks!! It worked. Thanks for ALL Your Help.
Nov 1 '07 #10
missinglinq
3,532 Expert 2GB
Glad we could help!

Linq ;0)>
Nov 1 '07 #11
Hello,

The report basicly workds for me, But I'm still having an issue properly formating decimal time to regular time in totals. I was thinking to email you guys the Database it's a small Access 2003 DB. Is anyone instrested in helping in this way?
Nov 29 '07 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Newbee Adam | last post by:
I have been reading in help how I need to use decimal becuase currency does not exist like I used in vb6. I had a difficult time on google and msdn finding how or if I can take the value of text...
2
by: Mariusz Sakowski | last post by:
I'm writing class which will be able to store large numbers (my ambition is to make it able to operand on thousands of bits) and perform various operations on it (similiar to those available with...
2
by: Steve Summit | last post by:
-----BEGIN PGP SIGNED MESSAGE----- It's often explained that the reason for some of the imprecision in C's definition is so that C can be implemented on different kinds of machines -- say, those...
7
by: Paul K | last post by:
I'm writing a small component that needs to be as fast as possible. The component needs to convert a string to decimal during the course of it's processing. However, I need to test the string...
3
by: Daniel | last post by:
I'm writing an application that (among other things) evaluates mathematical expressions. The user enters strings containing literals and names that later get evaluated using the Python interpreter....
5
by: Jeff Dillon | last post by:
How might I convert a string like 10.A (in hex) to it's decimal equivalent? Basically I have an input string like ((1F.A + 3A.D) - 1F.E) and need to calculate the result. Using Reflection and...
28
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places?...
4
by: Jeff | last post by:
Hey ..NET 2.0 In my code am I trying to convert an int value into a decimal: decimal d = 0; int k = 87664; d = Convert.ToDecimal(k/100);
10
by: Jason | last post by:
I'm making a program that will convert decimal inputs (in this case, in inches) and output a fractional answer. At the moment, I'm only able to output the fractional answer in three parts: A whole...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.