Calculating time
Author
Discussion

Sour Kraut

Original Poster:

45,899 posts

221 months

Thursday 13th January 2011
quotequote all
Why does this trouble computers?

Google will find you a calculator for pretty much anything. Mortgage calculators, inflation calculators, half-life calculators, there's a calculator for everything.

But not time.

There are very basic ones. Add or subtract hours, mins and seconds. But nothing that will touch days too. And multiplication and division seem completely alien.

So why is it so difficult?

evenflow

8,896 posts

314 months

Thursday 13th January 2011
quotequote all
I know what you mean. I've always presumed it was because of not being base 10, plus the different units (eg divide by 24 to get hours, divide by 60 to get seconds etc). Also, different months are different lengths, plus leap years etc etc

Cock Womble 7

29,908 posts

262 months

Thursday 13th January 2011
quotequote all
Why do you want to calculate time?

Haven't you got a watch?

Turbodiesel1690

1,958 posts

202 months

Thursday 13th January 2011
quotequote all
Clearly google don't offer such a calculator because they know the end is nigh, what with all the unexplained bird and fish kills and the completely fecked up world weather, they probably reckon the 4 horsemen of the apocalypse are saddling up as we speak

CypherP

4,459 posts

224 months

Thursday 13th January 2011
quotequote all
http://www.csgnetwork.com/timeconv.html

That one seems to do days as well as hours, minutes and seconds, but still doesn't do multiplication or division.

cal72

7,839 posts

202 months

Thursday 13th January 2011
quotequote all
Turbodiesel1690 said:
Clearly google don't offer such a calculator because they know the end is nigh, what with all the unexplained bird and fish kills and the completely fecked up world weather, they probably reckon the 4 horsemen of the apocalypse are saddling up as we speak
Now that you mention it, i was thinking of the end 21/12/2012 but could it actually be 2011 as the calendar only counts in years but in actual fact 2012 is 2011.
The end is truley nigh, head for the hills.

pugwash4x4

7,686 posts

253 months

Thursday 13th January 2011
quotequote all
excel can calculat time quite happily

Bebee

4,724 posts

257 months

Thursday 13th January 2011
quotequote all
cal72 said:
Turbodiesel1690 said:
Clearly google don't offer such a calculator because they know the end is nigh, what with all the unexplained bird and fish kills and the completely fecked up world weather, they probably reckon the 4 horsemen of the apocalypse are saddling up as we speak
Now that you mention it, i was thinking of the end 21/12/2012 but could it actually be 2011 as the calendar only counts in years but in actual fact 2012 is 2011.
The end is truley nigh, head for the hills.
Or on the date 31/12/2359 at 23:59 hrs.



Edited by Bebee on Thursday 13th January 10:40

plasticpig

12,932 posts

257 months

Thursday 13th January 2011
quotequote all
pugwash4x4 said:
excel can calculat time quite happily
To a point. If you want to find the number of yoctoseconds between two dates and times it's pretty useless without some programming.



onomatopoeia

3,526 posts

249 months

Thursday 13th January 2011
quotequote all
Maybe it's because time ends at 03:14:07 on 19/1/2038.

Sour Kraut

Original Poster:

45,899 posts

221 months

Thursday 13th January 2011
quotequote all
plasticpig said:
pugwash4x4 said:
excel can calculat time quite happily
To a point. If you want to find the number of yoctoseconds between two dates and times it's pretty useless without some programming.
I'm not sure it could even manage to divide a number of days by a set of hours and minutes. It likes dates, but not random quantities of time.

onlynik

4,294 posts

225 months

Thursday 13th January 2011
quotequote all
Sour Kraut said:
Why does this trouble computers?

Google will find you a calculator for pretty much anything. Mortgage calculators, inflation calculators, half-life calculators, there's a calculator for everything.

But not time.

There are very basic ones. Add or subtract hours, mins and seconds. But nothing that will touch days too. And multiplication and division seem completely alien.

So why is it so difficult?
Second result on Google.

http://www.timeanddate.com/date/timeduration.html

Why would you want to multiply dates?

Sour Kraut

Original Poster:

45,899 posts

221 months

Thursday 13th January 2011
quotequote all
onlynik said:
Sour Kraut said:
Why does this trouble computers?

Google will find you a calculator for pretty much anything. Mortgage calculators, inflation calculators, half-life calculators, there's a calculator for everything.

But not time.

There are very basic ones. Add or subtract hours, mins and seconds. But nothing that will touch days too. And multiplication and division seem completely alien.

So why is it so difficult?
Second result on Google.

http://www.timeanddate.com/date/timeduration.html

Why would you want to multiply dates?
I wouldn't want to use dates, that's the point. Just units of time.

e.g. 94 days divided by 7 hours 24 minutes. Or 7 hours 36 minutes multiplied by 29.

130R

7,135 posts

238 months

Thursday 13th January 2011
quotequote all
In computing terms a point in time is usually defined as the number of seconds or milliseconds that have elapsed since an Epoch (for example, midnight UTC January 1, 1970)

//j17

5,120 posts

255 months

Thursday 13th January 2011
quotequote all
You should be able to di it with a mix of the tools on www.onlineconversion.com

1) Convert dates to UNIX time (milliseconds).
2) Convert number of days/hours/minutes/seconds to millisecond).
3) A (+-/*) B
4) Convert from milliseconds to days/hours/minutes/seconds or from UNIX time to clock-time.

For your example of 94 days divided by 7 hours 24 minutes
94 days => 8121600000 ms
7 hours => 25200000 ms + 24 minutes => 1440000 ms => 26640000 ms
8121600000 / 26640000 => 304.86

Edited by //j17 on Thursday 13th January 12:11

I Love Lamp

2,664 posts

207 months

Thursday 13th January 2011
quotequote all
Sour Kraut said:
I wouldn't want to use dates, that's the point. Just units of time.

e.g. 94 days divided by 7 hours 24 minutes. Or 7 hours 36 minutes multiplied by 29.
Well, this depends on the output format you require?

Years, months, days, hours, minutes, seconds, miliseconds, nanoseconds.

And then there's the way this information is displayed. Colons, full stops?

What determines a day? A work day, 24 hour day?

Effectively you're requesting multiple calculations. You would like to know days (integers) divided by hours (decimals) or in the example you have given, something else (as .36 doesn't represent 36 mins).

So you'll need to know the calculation for hh:mm or hh:mm:ss into days, and then divide the original format by this calculation.

Result: Nobody can really be arsed I guess, but it's not much work.

mike_knott

344 posts

256 months

Thursday 13th January 2011
quotequote all
Sour Kraut said:
plasticpig said:
pugwash4x4 said:
excel can calculat time quite happily
To a point. If you want to find the number of yoctoseconds between two dates and times it's pretty useless without some programming.
I'm not sure it could even manage to divide a number of days by a set of hours and minutes. It likes dates, but not random quantities of time.
It is fine with time as it converts all dates and times to a number, which can then be mathematically manipulated. Type:
=94/"07:24"
in a cell, make sure the cell is formatted as a number, and it gives the answer as 304.86. Excel handles dates very well for most people's
requirements, but few people know how to use it.

Mike...

alock

4,578 posts

243 months

Thursday 13th January 2011
quotequote all
If you're on Windows, open a PowerShell window and type something like this:
(get-date "20-oct-2010") - (get-date "18-mar-2009")

What you get is (almost) all the detail you need. A quick Google will help you format it into what ever format you need.

The next question people ask is 'can it tell me how many years+months+days are represented by 581 days?' This cannot be answered directly as the number is different depending on how many 28, 29, 30 and 31 day months are within this range.

The problem arises because by this point the program has discarded the start date information. When you subtract integers (whole numbers) you get another integer as the result. When you subtract dates you get a TimeSpan result (not another date). The mathematics is like this:

Date1 + TimeSpan1 = Date2

A TimeSpan has no intrinsic start value and hence cannot be formatted to years+months+days. If it contained a start date it would make the above equation confusing. If you design you TimeSpan object to store years+months+days instead of total days then the basic rules of addition fail. How do you add 1 month to 31-jan-2011?

Dracoro

9,040 posts

277 months

Thursday 13th January 2011
quotequote all
//j17 said:
You should be able to di it with a mix of the tools on www.onlineconversion.com

1) Convert dates to UNIX time (milliseconds).
2) Convert number of days/hours/minutes/seconds to millisecond).
3) A (+-/*) B
4) Convert from milliseconds to days/hours/minutes/seconds or from UNIX time to clock-time.

For your example of 94 days divided by 7 hours 24 minutes
94 days => 8121600000 ms
7 hours => 25200000 ms + 24 minutes => 1440000 ms => 26640000 ms
8121600000 / 26640000 => 304.86
You don't need to go down to milliseconds, just the lowest type, in this case minutes.

94*24(hours)*60(minutes) = 135360
/
so 7 hours (7*60 = 420) and 24 minutes = 444
=
304.86 minutes

Or as I did it in spotlight 94*24*60/444 biggrin Simples wink

Then you can turn those minutes into hours so 304.86 / 60 = 5.1 hours.

Edited by Dracoro on Thursday 13th January 19:11

Sour Kraut

Original Poster:

45,899 posts

221 months

Thursday 13th January 2011
quotequote all
Dracoro said:
//j17 said:
You should be able to di it with a mix of the tools on www.onlineconversion.com

1) Convert dates to UNIX time (milliseconds).
2) Convert number of days/hours/minutes/seconds to millisecond).
3) A (+-/*) B
4) Convert from milliseconds to days/hours/minutes/seconds or from UNIX time to clock-time.

For your example of 94 days divided by 7 hours 24 minutes
94 days => 8121600000 ms
7 hours => 25200000 ms + 24 minutes => 1440000 ms => 26640000 ms
8121600000 / 26640000 => 304.86
You don't need to go down to milliseconds, just the lowest type, in this case minutes.

94*24(hours)*60(minutes) = 135360
/
so 7 hours (7*60 = 420) and 24 minutes = 444
=
304.86 minutes

Or as I did it in spotlight 94*24*60/444 biggrin Simples wink

Then you can turn those minutes into hours so 304.86 / 60 = 5.1 hours.
Erm... so you think that the answer to 94 days divided by 7h24m is 5.1 hours?

Really?

Without using a calculator, there are about 3 'lots of' 7h24m in a day, so the answer is c.3x94.
Which is c.282.

And there's no applicable unit, surely? It's just a multiplier.