HI::
I have an Access Database that automatically collects data from an industrial proccess, each minute I have a new record, then I can count the records and have the amount of time the proccess was on or off, dividing by 60 I can have the Hours; so far fine , now I'd like to convert the resulting digital time into time with format like hh:mm, any ideas how to do it ?
Tks in advance for your help
Raymundo Walle
To convert decimal minutes to a time-format value simply divide by 24 * 60.
Date/Times are stored as whole days and fractions of them, thus 5.5 would represent 5 1/2 days. Divide that by 24 to get 5.5 hours, then again by 60 to get 5.5 minutes.
To prove the value, simply format your result to see what turns up. - dblValue = 5.5
-
-
dblValue = dblValue / (24 * 60) 'x / 1440
-
-
Debug.Print Format(dblValue, "HH:nn:ss")
9 1407
unless I am misreading your question, you already asked this here
On second read I think I understand now.
Do you mean you have a decimal value representing a time
ie
5.75 minutes as a decimal value which is 5:45 minutes as a time value
That will be a mathematics exercise
yes Delerna::
I have the decimal value 5.5 and need to have 5:30 Hrs
R Walle
- Public Function fncTimeFormat(db_input As Double) As String
-
'Number of hours
-
Dim intHours As Integer
-
intHours = Fix(db_input)
-
-
'Number of mins
-
Dim intMin As Integer
-
intMin = (db_input - intHours) * 60
-
-
'Output
-
fncTimeFormat = Format(intHours, "00") & ":" & Format(intMin, "00")
-
End Function
There may be other smarter ways of doing it. This is just my 5 cents.
The value can ofcourse be converted to time units by using: - cdate(fncTimeFormat(5.5))
which would give the result:
05:30:00
NeoPa 32,556
Expert Mod 16PB
To convert decimal minutes to a time-format value simply divide by 24 * 60.
Date/Times are stored as whole days and fractions of them, thus 5.5 would represent 5 1/2 days. Divide that by 24 to get 5.5 hours, then again by 60 to get 5.5 minutes.
To prove the value, simply format your result to see what turns up. - dblValue = 5.5
-
-
dblValue = dblValue / (24 * 60) 'x / 1440
-
-
Debug.Print Format(dblValue, "HH:nn:ss")
Interesting Neopa and TheSmileyOne
Heres the approach I normally take within a query -
cstr( cint(DecVal) ) & ':' & cstr( 60 * ( DecVal - cint(DecVal) ) )
which is similat to TSO's first example
I might need to change that.... if I can remember yours ... next time :)
NeoPa 32,556
Expert Mod 16PB
I can see where you're coming from, but you should remember the result is supposed to be in numerical format. Converting the type of data for display purposes should only ever be done at the last stage, when interfacing with the user (display on screen etc). Otherwise you are working with foreign principles which need to be converted (for you automatically in most cases but nevertheless extra work). Sometimes such conversions allow unexpected issues into your calculations.
I'm probably overstating the isuue here, but I'd strongly suggest to any of you guys who are serious about your design to understand and work with the different formats data is stored in and worked with.
Thanks all for your reply, I took Neopa approach since looks simplest way to do it, also thanks for the info about how the Time/ date are handled by Access it helps understand date time calculations
Raymundo Walle
NeoPa 32,556
Expert Mod 16PB
You're welcome Raymundo :)
Welcome to Bytes!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: dan glenn |
last post by:
Say,
I want to set a cookie and have it expire an hour after it's set. It's
looking like this is only possible for browsers which are in the same time
zone as my server??
In other words, if I...
|
by: learning_C++ |
last post by:
I programmed this code with a function "get_current_time" in the
begining. When I compiled with the command g++ -Wall -g xxx.xpp -o xxx
there are so many errors.
please help me and thanks,
...
|
by: heirou |
last post by:
I'm a novice in this subject....I've made a database that requires a
time conversion. For example, if local time is 1200, determine the
time in Korea. I use two fields: a date field, and a time...
|
by: DCSudolcan |
last post by:
I know that a program can create and properly initialize an array of pointers
to functions at build time, but can something like the following be done at
build time?
void foo(void);
unsigned...
|
by: Paulers |
last post by:
Hello,
I'm working on an app that requires the functionality to convert the
time in Austrailia to the time in New York (EST). I am wondering, what
is the bestway to approach this in vb.net? Is...
|
by: Jason S |
last post by:
is there any way to use templates to bind integer/floating point
constants to a template for compile-time use?
e.g.
template <double conversion>
class meters
{
const factor = conversion;
|
by: moni |
last post by:
Hi,
I wanted to convert a time value in the form of time_t into a readable
form in C# or vice versa, in order to be able to subtract two time
values and give the result in msecs.
eg.
I...
|
by: Evan Klitzke |
last post by:
Although it is not present in ANSI C, the GNU version of stftime
supports the conversion character %z, which is a time offset from GMT.
The four digit time offset is required in RFC 2822...
|
by: fimarn |
last post by:
I am trying to get rid of compile time error that I am getting only in
RHEL5
(not in RHEL4) apparently due to the changes in the stl_list.h file.
The error that I am getting is coming from the...
|
by: Grey Alien |
last post by:
I need to convert timestamps that are given as the number of seconds
that have elapsed since midnight UTC of January 1, 1970, (not counting
leap seconds).
It seems all of the std C functions...
|
by: DolphinDB |
last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation.
Take...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
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...
|
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)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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....
| |