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

How can I calc a percentage of an hour?

49
Access 2010:

I need to calc the difference between two times then calc a percentage of an hour?

Expand|Select|Wrap|Line Numbers
  1. !StartTimeStamp1 = StartTime
  2. !EndTimeStamp1 = MDrs("TimeStamp1")
  3. !Total_time = MDrs("TimeStamp1") - StartTime
First problem, the above code is giving the following result, adding 12 hours when the difference is less than one hour. See attachment.



Second problem I cannot find a good example to calc a percentage of an hour. i.e. if the above field "Total_time" = 29:51 then I want to calc 29:51 / 60:00 = .4975

Hope I explained my problem correctly
Attached Images
File Type: jpg Time Example.jpg (29.0 KB, 416 views)
Mar 16 '12 #1

✓ answered by Rabbit

The results are correct. 12:29:51 AM is 29:51 minutes from time 0 which is 12:00 AM, or in 24 hour format, 00:00:00. In 24 hour format, it's 00:29:51. In 12 hour format, it's 12:29:51. There is also a date component that you don't see.

You seem to think that there is a time only data type. There is no such data type. They are all date AND time data, even if you don't display one or the other.

To calculate a percentage of the hour, Get the number of minutes, multiply by 60, add the number of seconds, then divide by 3600. That's if you want it down to the precision of a second. If you just care about the minutes, take the number of minutes and divide by 60. Use the DATEPART function to grab a section of a date time field.

1 1986
Rabbit
12,516 Expert Mod 8TB
The results are correct. 12:29:51 AM is 29:51 minutes from time 0 which is 12:00 AM, or in 24 hour format, 00:00:00. In 24 hour format, it's 00:29:51. In 12 hour format, it's 12:29:51. There is also a date component that you don't see.

You seem to think that there is a time only data type. There is no such data type. They are all date AND time data, even if you don't display one or the other.

To calculate a percentage of the hour, Get the number of minutes, multiply by 60, add the number of seconds, then divide by 3600. That's if you want it down to the precision of a second. If you just care about the minutes, take the number of minutes and divide by 60. Use the DATEPART function to grab a section of a date time field.
Mar 16 '12 #2

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

Similar topics

1
by: Put 030516 in email subj to get thru | last post by:
I've always been bothered about having to statically declare the size of a Java applet window (container?) in the calling HTML. I've always wanted the moral equivalent of width=50% statement (of...
0
by: Stewart Midwinter | last post by:
After an hour of research, I'm more confused than ever. I don't know if I should use the time module, or the eGenix datetime module. Here's what I want to do: I want to calculate the time...
3
by: Astra | last post by:
Hi All Wonder if you can help me with the following calc, which I want to create to check whether or not a user has entered a valid credit card expiry date: 1) I have retrieve a value from 2 x...
16
by: PeteCresswell | last post by:
I was happily coding along, putting some calculation results (rolling annualized rates of return - too compute-intensive to calculate on-the-fly - had tb staged beforehand via a batch job) into...
0
by: fake ID | last post by:
Since you can't search for these symbols used in asp.net "<%#" or '<%=' I thought i'd post this to make things a little easier to find. Potential search word combinations: -lessthan Percentage...
2
by: mtech1 | last post by:
Access 2003 I need to create a query to view data by 3 - 24 hour shifts. Ex: There are 3 shifts, each shift is 24 hours starting at 0700 through 0700. Each shift is designated as A, B, or C. ...
21
by: mm | last post by:
(Yes, I konw whats an object is...) BTW. I did a translation of a pi callculation programm in C to Python. (Do it by your own... ;-) -------- Calc PI for 800 digs(?). (german: Stellen) ------...
5
by: Aswanth | last post by:
I'm Using Asp.Net with C# & Working with SSRS 2005 for Generating Reports.. The Following Expression I'm using in Reports to Show the Percentage of Particular Items in REPORT.. ...
1
by: karpalmera | last post by:
Hello! We are trying to delete 1,500 records from a parent table with two child tables and it is taking hours to execute. Here is the set-up. - The parent table has 800,000 records. Child...
0
by: Prashant Gadeka | last post by:
Hi, I am having following table structure and sample values: ---------------------------------------------------------- APP_ID DATE HOUR STATUS_CODE HITS ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.