Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Work out the percentage of the day that has elapsed

Slightly strange question, but hopefully someone can help.

In essence, if the time was 12pm the the elapsed percentage would be 50%, 6am would be 25% and 16pm would be 75%.

Given the current time, how could you work out the amount of day that already passed?

like image 823
Tom Avatar asked Jan 26 '09 08:01

Tom


People also ask

How do you find the percentage of the day that passed?

By definition, percentage is a fraction or ratio expressed as part of 100. To determine the expired hours percentage, divide the expired hours of the day by the hours in the day. Decimal fractions of an hour are legitimate.

How do I calculate percentage progress in Excel based on dates?

Please use this formula: =MIN(1, (DATEDIF(B2,TODAY(),"d")+1)/(DATEDIF(B2,C2,"d")+1)). It will maintain it at 100% instead of 100 over percent if today date is exceed the end date.


2 Answers

Assuming you can get the current time of day, it'd be pretty easy to calculate the percentage of the day elapsed.

percentage = (hours / 24 + minutes / (60 * 24)) * 100
like image 176
sykora Avatar answered Oct 09 '22 16:10

sykora


24hours are 100% so 24/currentTime = result 100 / result = % ;)

like image 35
Sebastian Avatar answered Oct 09 '22 16:10

Sebastian