How to convert UTC to PST in Excel for day and time formats? - excel

In excel, I have a cell which is
13 05:58:57
which represents day 13, 5 am, 58 minutes, 57 seconds in UTC time.
I would like to convert to PST, which should be
12 10:58:57
which is day 12, 10 pm, 58 minutes, 57 seconds.
The day is just a day of the month. Is there a way to do this quickly in excel?

Excel stores date_times as numbers, where each day is 1, and the decimal part of the number is the time (so 0.25 is 6 hours, and 0.7 is 16 hours + 48 minutes)
Time 0 is the beginning of 1899/12/31, so =today() formatted as a decimal currently shows me as 44730.4556, being 44730 days since 1899 and almost eleven a.m.
Once you have your data in that format it is trivial to E.g.:
subtract 7 hours = A2 - 7/24
add 2 days 6 hours and 15 minutes = A2 + 2 + 6/24 + 15/24/60
find the difference between two date_times
So you want to get the input data into that form, from which point you just use formatting.
To see where you are going, enter in A1 = now(), in B1 =A1, in C1 = B1.
Change the format on B1 - Right Click | Format Cells | Custom | yyyy-mm-dd hh:mm:ss.
Then in C1 try changing to a format you want: dd hh:mm:ss AM/PM.
For a full list of options see https://support.microsoft.com/en-au/office/format-numbers-as-dates-or-times-418bd3fe-0577-47c8-8caa-b4d30c528309
I will assume that your data starts at A4, but I can't tell what is actually stored in the cell, as opposed to what it displays.
If your input data is actually already a date_time (what does it look like if you format is as a decimal?) all you need to do is =A4-7/24.
If your input data is actually a string, then separate it into day, hour, minute, second in C, D, E, F.
If single-digit days have leading zeros then just =left(A4,2) then =mid(A4,4,2) etc.
If there are no leading zeros put in column B =find(" ",A4) and point the lefts and mids to that intermediate result.
Then in G put = C4 + D4/24 + E4/24/60 + F4/24/60/60 so you have the input data as an Excel-formatted time.
And subtract the 7 hours difference with =G4-7/24
P.S. If you need to cope with month-ends and DST then you need to add year and month to the data in G - currently it has date_times in January 1899.

Related

How do I calculate this time? Across midnight

I have a sheet with start and end dates and values.
In C I have start date.
In E I have end date.
In I I have start time. (06:05:00)
In J I have end time. (08:33:00)
If C <>E I need to add 24 hours to the time elapsed.
How can I do that?
I tried if(C2<>E2;1+J2-I2;"omitted")
But I get the result 21:32:00.
It should be about 26 hours
(24+8-6 = 26 if we only look at the hours).
What have I done wrong?
Edit;
Back at work and can now upload some images.
Method 1
Method 2
Both return the wrong time.
EDIT2;
Method 3
I remember how I always have to format the dates from "our" format to Excels format for it to be recognized as a date.
In column P I use RIGHT(), MID(), and LEFT() to make a correct formatted date.
In R and S I use the same as P&Q column.
Still not correct.
:-/
EDIT again:
Use formula: =(E1+J1)-(C1+I1) we just add the date and time together and subtract the end from start and then format the cell having the formula to show days, hours, minutes.
This way, if you have more than 1 day difference, you're not just adding 24 hours.
Change the format of the target cell contianing the above formula to
d "days" hh "hours" mm "minutes"
or use the format tigerAvatar suggested of [hh]:mm if you want the hours to be cumulative across days.
Then you get a nice output of: 2 days 02 hours 28 minutes or 50:28
Feel free to drop the 1 h or 1 m if you don't want the leading zeros.
A picture is worth a 1000 words so:
Version 2 after your screenshots: I don't think C, E are in date format based on your updates so...
I used formula=(DATE(LEFT(E2,4),MID(E2,5,2),RIGHT(E2,2))+J2)-(DATE(LEFT(C2,4),MID(C2,5,2),RIGHT(C2,2))+I2) in K and custom format mask: [h]:mm
If this doesn't work it may be a regional setting and the interpretation of [h]:mm I am assuming I/J are time formats.

Adding/Subtracting Whole numbers from Time

I have tried every which way to format cells to subtract the result from time for instance the formula in the cell = 11(this is 11 minutes) I want to take that result minus 8:00:00 to give me 7:49:00 but it doesn't work the result is ####### no matter how big I make the cell. And if I format the cells with the formula to custom [m]:ss then the value changes.
Sample of the Worksheet:
I want Y2 = X3-W3 in a time format.
So, if A1=11
Then in some other cell, (B1 in this example): =TIME(,A1,)
Then subtract from the cell with 8:00:00. (If it's C1...:)
=C1-B1
That will give you the time you want.
Info: The main thing is that you have to tell Excel that your cell with the "11" in it, is minutes. By using the =TIME(,A1,) you will get the value of: 12:11 am. (If you keep it in Date format.) 12:11 am could also be viewed as: 0 Hours, 11 minutes, 0 seconds. And now that it knows, you should be able to subtract.
Try this:
=TIME(HOUR(X3),MINUTE(X3)-W3,SECOND(X3))
The ######### is because you have a negative time. Becuase Excel reads time as decimals of 24 hours, 8:00:00 is .3333 and if you subtract 11 from that you get -10.6666 and date/time can not be negative.

Calculating the average difference in days within a period

I am trying to calculate the average difference between two columns in excel. The columns contain a planned and an actual date, I would like to get the average difference but only for planned dates within the last three months.
Example:
Planned Start Date | Actual Start Date
21/09/2013 | 25/09/2013
10/07/2014 | 16/07/2014
01/06/2014 | 30/06/2014
The formula should only take line 2 & 3 (line 1 is older than 3 months), look at the difference in days for each applicable line (line 2: 6 days, line 3: 29 days) and then show the average ( 17.5 days) of all applicable lines.
Does anybody have a formula for this? Excel really isn't my strong suit...
Assume your data is in A2:B4 then try this array formula
=AVERAGE(IF(TODAY()-A2:A4<=90,B2:B4-A2:A4))
It assumes each month is 30 days (hence the 90)
Press CTRL + SHIFT + ENTER to enter the formula as an array formula
Based on your example I get a result of 17.5 days.

Excel date values compute incorrectly

I am trying to create an excel sheet where each line contains a date/time field for each 15 minute interval for the entire year. I put "00:15:00" in A1 and "1/1/2014" in A2 and "=A2+$A$1" in A3. I then copied A3 down enough times to go thru the year. I set column B equal to col A. I set the format in col A to Short Date and col B to Time. Then I converted everything to values. When I do that, all the entries for midnight are not right. For example the entry between Jan 1 and Jan 2, displays as 1/2/2014 and 12:00:00AM. But the actual value is "1/1/2014 12:00:00 AM". This value is incorrect, it is 24 hours off. What's going on here? How can I fix it?
I'm using Office 2010.
It's standard for 12:00 AM to denote the midnight that starts the day. So, in 15-minute increments, 1/1/14 11:45 PM would typically be followed by 1/2/14 12:00 AM, followed by 1/2/14 12:15 AM.
See: http://en.wikipedia.org/wiki/12-hour_clock#Confusion_at_noon_and_midnight

Excel 2013: Convert Hours and Minutes from hh:mm:ss formatted cell in decimal number

I use Excel 2013 and have a cell with the following value:
"08.01.1900 1:45:00"
that will be displayed inside the cell as: "193:45:00" - meaning 193 hours, 45 minutes and 00 seconds (see the first image below).
Here is screen of how it looks like and the formatting of the cell
[how it looks like]
QUESTION: How I can in cell "Salary" to get decimal number, like - 193,45? Help me, please.
The cell is formatted as Time (see the image below)
So, you have Q2 = 12:30 (or 12,5 hours where 0,5 hour=30min) and R2 = 15,5 UAH/hour and since you want to calculate salary, you should multiple 12,5*15,5=193,75.
Follow next steps to achieve the desired result:
Write next formula in S2: =Q2*24*R2 (since time stored in Excel as part of a day, we need to multimply by 24 . Your value 12:30 is actually 0,520833333333333 ,you can see it if you'd format Q2 as number. Myltiplication 0,520833333333333 by 24 gives you exactly 12,5)
Format your S2 as number
the result would be 0,52*24*15,5 = 193,75 and this value is what you actually need.

Resources