I want to convert the time HH:MM
into H.xx
Like I am getting it in this format: Sat Dec 30 00:00:00 GMT+05:21 1899
But this value is 04:29
in cell. I want it to be 4.5
hours to multiply it to hourly rate.
This online tool will help you convert time given in hours and minutes to decimal hours and/ or decimal minutes. 7 hours 15 minutes is 7.25 hours or 435 minutes.
The easiest way to convert time to decimal in Excel is to multiply the original time value by the number of hours, seconds or minutes in a day: To convert time to a number of hours, multiply the time by 24, which is the number of hours in a day.
In Google Sheets, if you have a date/time value in a cell (e.g. "D9"), then use =HOUR(D9)+(MINUTE(D9)/60)
.
If the value is stored in the format 04:29
, then use =INDEX(SPLIT(D9, ":"), 1) + (INDEX(SPLIT(D9, ":"), 2)/60)
.
If you want to use the Google Sheets API or Google Apps Script, then you can use javascript.
You need to use the getMinutes() method and divide by 60, then add that to the hour (using getHours()).
var date = new Date(); var minutes = date.getMinutes(); var output = date.getHours() + (minutes/60);
Be aware that this is ignoring seconds.
If the value in the cell is stored as a string like 04:29
, then you'll need to split it.
var time = "04:29"; var hour = Number(time.split(":")[0]); var minutes = Number(time.split(":")[1]); var output = hour + (minutes/60);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With