This question already has an answer here:
Converting large time format to decimal in excel
(1 answer)
Closed 5 years ago.
I have a function =TIME(8,30,0)-(C2-B2) that work out my timesheet for me but I also need the resulting elapsed time value to be converted into hours and 100ths of an hour.
e.g. 1:45:00 would be 1.75.
Multiplying the result by 100 and dividing by 60 does not seem to give the desired result.
Time in Excel is a decimal. so one hour is 1/24th of a full day. So 1/24.
Multiply the time by 24 and you will get your decimal:
=A1*24
Related
I'm using manipulating time in excel.
I have the date in minutes I want to convert it into the format.
YY MM DD HH mm
where:
mm:Minutes
HH:Hours
DD:Days
MM:month
YY: year
Im using the following logic:
For 124 minutes I have
124/60= 2 hours
124%60 = 4 minutes
and so on for the days and the months and the years
The units Im using are:
mm-> HH /24
HH-> MM /30
MM-> YY /12
But something is really wrong:
Does anyone have an idea what was happening?
Thanks a lot, guys
Your calculations are "really wrong" because in real life, months have anywhere between 28 and 31 days, so you cannot represent a large number of minutes as a "date" that uses variable measures for years and months.
On the assumption that as units of measure you want to use ...
Year = 360 days
month - 30 days
... you can calculate as follows:
That's also what your calculation shows. If something is "really wrong" with that, it's probably your expectation, which is based on the traditional 365.25 day year.
Maybe you want to edit your question and explain what you expect as the "really correct" result.
In Excel dates are fractional number of days from 31-Dec-1899 (date 0 is formatted as 0/1/1900). So why don't you just add your minutes (after dividing by (24*60) to convert to days) to the earliest valid date in EXCEL (1900-01-01) and use the TEXT function to format:
=DATEVALUE("1900-01-01")+(21/24/60)-1
The bold part is your minutes.
This is now a proper EXCEL date; you can use TEXT function to format it into any way you like, or you can use DAY(), HOUR(), etc. functions to extract parts.
Having said that I don't know what your minutes represent; What date does Full Time in Minutes:21 correspond to?
This question already has answers here:
pd.to_datetime is getting half my dates with flipped day / months
(2 answers)
Closed 3 years ago.
I'm doing some data analysis using Pandas in a Jupyter notebook and analysing minute by minute data for a 2 year period. There's about 740,000 rows of data pulled in from a csv file (pd.read_csv('file location'))
Format of date_time: "dd/mm/yyyy hh:mm" - i.e. 11/01/2017 21:52
Here's something weird I've found, when day<=12, the day and month switch, when the day is 13 and above the format is correct (when put through pd.Timestamp)
An example:
pd.Timestamp("13/02/2018 02:26")
--> Timestamp('2018-02-13 02:26:00')
As you'd expect. Now taking it to 11th February:
pd.Timestamp("12/02/2018 02:26")
--> Timestamp('2018-12-02 02:26:00')
Really unsure why this happens, would really appreciate some help on how I can avoid this happening.
Thank you!
Check with to_datetime and dayfirst
pd.to_datetime("11/02/2018 02:26",dayfirst=True)
Out[22]: Timestamp('2018-02-11 02:26:00')
This question already has answers here:
1 microsoft second = 0.00001157407407
(3 answers)
Closed 4 years ago.
I have a column of time values in excel that are from exporting from another piece of software. The time is formatted as hh:mm:ss.sss (e.g. 00:00:02.147 -> 0 hrs, 0 min, 2 s and 0.147 ms).
I want to change this into total number of seconds in excel however any function performed on the cells results in a #VALUE! error. I have tried changing the cell type from General to Text to Time to Custom (i.e. [ss]) etc. however nothing has worked. Is there anyway I can do this? This also causes issues for plotting in python.
The custom format of "hh:mm:ss.000" should do what you are after.
You can then narrow that down to "ss.000" and just use =A1 or even just nab the seconds with =SECOND(A1) (if you wanted to do this long-hand then you can do a =RIGHT(A1,6) with a format of "ss.000" or even =TEXT(A1,"ss.000") / =TEXT(RIGHT(A1,6),"ss.000").
The issue being that using "ss.sss", excel is trying to append seconds on to time again rather than milliseconds, so if excel can first know the milliseconds exist you should be able to extract the seconds.
EDIT
If it's the total number of seconds you are after, multiply the DateTime value by the number of seconds in a day: =A1*86400
I need to change a value of time from days:hours:minutes, into either hours with a decimal or minutes. My data comes up as 001:05:46 for example. I am having trouble with the leading zeros confusing excel. Any help would be great!
Assuming that your value to parse is formatted in DDD:HH:MM like 001:05:46... There are a lot of ways to do this but here's a simple one. To convert into hours we need to take the days times 24 hours per day, add the hours, and add the minutes times 1 hour per 60 minutes:
=LEFT(A1,3)*24+MID(A1,5,2)+RIGHT(A1,2)/60
To get this value in terms of minutes we multiply by 60 minutes per hour. A possible modification of the original formula to reach this point would be:
=LEFT(A1,3)*24*60+MID(A1,5,2)*60+RIGHT(A1,2)
This question already has answers here:
Convert decimal day to HH:MM
(3 answers)
Closed 3 years ago.
I have a dataset that encodes a date-time into two separate variables. Normally, I'd just paste them together inside of an as.POSIXct and carry on. However, the date is provided as a string, and the time of day as a fraction of 24 hours - e.g., 12pm is 0.5, 9:30am is 0.1458333, etc.
It doesn't seem all that tricky to convert the fractional days into clock hours, but I'd prefer to use a pre-existing function if possible. Does something like that exist in base R? A package?
If it's any use, this is an Excel (xlsx) time field imported into R through RODBC.
EDIT
Oddly enough, upon revisiting this problem, the times are now read in as POSIXct. Not sure what to make of that.
The R News 4/1 Help Desk article has a section on reading Excel dates in R.
POSIXct values are simply the number of seconds since midnight GMT 1970-01-01. (So you need to pay attention to your offset from UTC.) You can use the date part and add the number of days times 24*3600 (as.Date(dtval) to your time value * 24*3600. Gabor pointed to the article in R News (which he wrote, thank you, Gabor.)
You didn't give an example of the string. If you are getting your date as a string, then as.Date(strDate) will convert a variable "strDate" to Date class when it is in either "YYYY-MM-DD" or "YYYY/MM/DD" format. Otherwise the formatting codes are on the ?strptime page.
Once you have a POSIXct-classed variable you can just add the number of seconds. This example add 30 minutes to midnight today Feb 1, 2011 (in my time zone which is UTC-5):
> as.POSIXct(as.Date("2011-02-01")) +30*60
[1] "2011-01-31 19:30:00 EST"
And this is your time value added to midnight my time:
> as.POSIXct(as.Date("2011-02-01 00:00", tzone="UTC"))+3600*5 + 3600*24*timeval
[1] "2011-02-01 03:29:59 EST"