Solved Working with time: Showing elapsed time as base 10 number (1 Viewer)

KitaYama

Well-known member
Local time
Today, 09:41
Joined
Jan 6, 2022
Messages
1,541
It's an extended question to this post. My question is a bit different, so I started a new thread.
It also may be more a math question than an Access one, but since I don't know the correct terminology, Google couldn't help.

I have a text box that shows a calculated elapsed time between two given date/time values.
example : 2 18:30:27 (2 days, 18 hours, 30 min & 27 sec)

How can I show this value as a 10 base number?

Some examples:
1 1:30:00 --> 25.5
0 1:15:00 --> 1.25

Thanks for any kind of advice
 
Last edited:

jdraw

Super Moderator
Staff member
Local time
Yesterday, 20:41
Joined
Jan 23, 2006
Messages
15,379
Kitayama,

Do you have any summations where the total is less than 1 day?
 

KitaYama

Well-known member
Local time
Today, 09:41
Joined
Jan 6, 2022
Messages
1,541
Kitayama,

Do you have any summations where the total is less than 1 day?
Yes.
In some cases even less than an hour.
You can find a sample database attached to the first post here
 
Last edited:

jdraw

Super Moderator
Staff member
Local time
Yesterday, 20:41
Joined
Jan 23, 2006
Messages
15,379
10-4.
I only asked because I didn't see an example in the thread with a leading 0.
Happy New Year!
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Yesterday, 19:41
Joined
Feb 28, 2001
Messages
27,193
Problem: Find days, hours, and decimal hours in a time variable that either IS an interval or is the sum of several related but non-contiguous intervals.

Input: (Given by asker) dddd hh:nn:ss - and at least one space is important if there are any numbers of days.

Requirement: The input variable must be converted into DATE format. This is important for two reasons. (a) As a typecast of DOUBLE, it will have sufficient numbers of bits to hold the desired information. (b) As a typecast of DOUBLE, it will work in various formatting routines.

Solution: (This is code for illustrative purposes only. It may require tweaking and will contain "extra" variables to make certain steps explicit.)

Code:
Function Cvt_DHNS_to_DHFrac( sDHNS as String ) as String
    Dim sWrkDHNS as String, sDays as String, sHNS as String
    Dim lDays as Long, dtHNS as Date, lSpace as Long
    Dim dFrac as Double
'   Remove extraneous leading/trailing spaces
    sWrkDHNS = Trim$( sDHNS )
'   Locate interior space, which a TRIM would not remove or shrink
    lSpace = InStr( 1, sWrkDHNS, " " )
'   Separate the parts - but allow for there to be no days part
    If lSpace = 0 Then
        sDays = "0"
        sHNS = sWrkDHNS
    Else
        sDays = Left$( sWrkDHNS, lSpace )
        sHNS = Mid$( sWrkDHNS, lSpace + 1, Len( sWrkDHNS ) )
    End If
'   Convert hh:nn:ss to a time
    dtHNS = CDate( "#" & sHNS & "#" )
'   Build formatted H.frac string
    dFrac = CDBL( dtHNS )
'   Make the fraction into whole numbers of hours - but leave it as a fraction
    dFrac = dFrac * 24
    sWrkDHNS = sDays & " " & Format( dFrac, "##.#" )
'   Return the converted string
    Cvt_DHNS_to_DHFrac = sWrkDHNS
End Function

If you wanted more decimal places, just tweak the formatting template.
 

NauticalGent

Ignore List Poster Boy
Local time
Yesterday, 20:41
Joined
Apr 27, 2015
Messages
6,341
i believe that.
in fact he set up his Blog long before NolongerSet, set his own.
and yet never been considered to become an MVP?
what is the criteria? backers? color?
I have seen his contributions on LinkedIn and knew he was a "heavyweight" and I completely agree with AB's post. For a heavyweight like yourself to find value in his site affirms this.

As to why he isn't an MVP, it could be that he doesn't feel the need to have the title to know his worth or even WANT the title. It could also be exposure. It is my understanding that to be a MVP, you have to be recommended by fellow MVP's. To do that, you would have to go where other MVP's go and you yourself seem to recently become aware of him.
 

jdraw

Super Moderator
Staff member
Local time
Yesterday, 20:41
Joined
Jan 23, 2006
Messages
15,379
apr pillai's site is very complete with lots of articles well categorized and suited to the new and experienced user/developer. His blog posts have been available for years. A great learning and reference resource.
His site has been listed in my Database Planning and Design (signature link) for a long time.
 

Users who are viewing this thread

Top Bottom