I have 2 columns, date opened and date closed which have timestamps for an excel sheet with thousands of rows.
A B
1 Date Opened Date Closed
2 07/16/2019 04:19 PM 07/24/2019 11:39 AM
Issue:
If I try Days360(A2,B2) I get ####### as output. On taking cursor over the cell of Days360(A2,B2) I get message, days too large value or negative hence shown as ####
Same problem of ###### with Datedif.
=month(B2) & '/' day(B2) & '/' & year(B2) also does not work
Is there any way to calculate number of days between 2 timestamps?
=MONTH(B2) & "/" & DAY(B2) & "/" & YEAR(B2)
This works. Apparently you need double quotes and not single quote around /.
Related
I have a time in a cell, want to minus 2 hrs and add 2hrs to the time and display in excel
Example : 02/08/2020 11:00AM
So Minus 2hrs and plus 2 hrs next cell must display as 9:00AM-13:00PM
I tried the below formula but displays like 43811.0577893518 - 43811.2244560185
=CONCATENATE(A1-TIME(2,0,0)," ","-"," ",A1+TIME(2,0,0))
Subtract & add two hours (2/24) to your date
=TEXT(A1-(2/24),"hh:mm AM/PM") & " - " & TEXT(A1+(2/24), "hh:mm AM/PM")
Use TEXT to format the output:
=CONCATENATE(TEXT(A1-TIME(2,0,0),"HH:MM AM/PM")," ","-"," ",TEXT(A1+TIME(2,0,0),"HH:MM AM/PM"))
Hi I am working on an employee schedule that currently looks like:
Where "# of employees on by hour" is a count of Employees that will be on at the Hour in C9:C33. 1 denotes working that day. I manually entered the numbers in the highlighted area but that's what I need to get. So Logic is Count IF C*>=(B2:B7) & C*<(C2:C7) & (D2:D7)>0
Use a =COUNTIFS():
https://support.office.com/en-us/article/COUNTIFS-function-dda3dc6e-f74e-4aee-88bc-aa8c2a866842
=COUNTIFS($B$2:$B$7, "<=" & $C#, $C$2:$C$7, ">" & $C#, D$2:D$7, ">0")
Excel's assumptions about cells are confusing the heck out of me. I'm on Office 365 - Excel for Mac, Version 15.28.
I'm TimeRecording on a lot of things, I would like to calculate relations and tendencies on the different things. I've exported my log-files, and have opened it in excel. A simple version looks like this:
In the real sheet, then I have 40+ tasks and 50+ dates. I would like to be able to do some calculations on these data. But Excel doesn't 'know what it is' (time durations) and therefore can't add them up or do anything.
So one question would be, to how to let Excel know, that this is time durations? I tried doing what this question suggests. But when I format the cells as [h]:mm then it gives me this error:
FYI: In the big sheet, then there's so many times, so the total amounts up to something along the lines of 633:33.
I would just like to be able to do simple calculations, such as:
=SUM(B1, C4, D5)
or
=SUM(B1, C4, D5)/COUNT(B1, C4, D5)
And maybe also make some charts and graphs.
Another attempt I've done is to try to get all the cells to have the format hh.mm instead of hh:mm, but this gave me problems. My approach was this:
Convert all the cells to 'Text' to tell Excel: 'Hey... Don't do any auto-converting/guessing here, and don't turn any of the cells into dates or decimal numbers or fricking origami swans!'
After that then I make a simple 'Replace all' of : to .
But after the 'Replace all', then 633:33 turns into 633.36.00 (even though the cell was a 'Text' cell).
And if I then simply double-click on the cell to edit it, then the numbers 'magically' turns from 633.36.00 to 27/01/1900 15.36.00 ... What the hell!? I need a procedure that doesn't require me to go through all my thousands of numbers and edit any of them (or ensure that Excel have turned the numbers into flying unicorns.
EDIT1
Here's an example of the total sheet I'm working on in Google Sheets.
EDIT2
If I format the cells as [h]:mm, then I get an error (see above). But if I format it as [t]:mm, then I don't get an error (thanks to Axel Richter for pointing that out). It may have something to do with the initial language of my Excel-installation (danish).
However... If I then try to sum up a bunch of cell, after doing this formatting to everything, then it sums up to 0:00.
If I format all the cells to Time (well-knowing that it's the wrong format, but hoping that Excel can see it and fix it) - and thereafter trying to sum up a couple of cells, then it sums up to 00.00.00 (even though it wasn't empty cells).
Is it also important, that when I sum up some numbers, that I do it from a General-cell - or does Excel know, that if I start with the =-sign, that it's going to be a calculation (and therefore the cell-format doesn't matter)?
Excel will store date-time values as floating point double values in following form:
1 day = 1
1 hour = 1/24 = 0.0416666666666667
1 minute = 1/24/60 = 0.000694444444444444
So formatted as time all values greater than or equal 0 but lower than 1 will be from 00:00 to 23:59. Values greater than 1 will be dates with 1 = 01/01/1900 00:00:00. But if you are formatting such values as time only using hh:mm for example, then only the time is shown. The date is simply hidden.
For example 1.25 formatted using hh:mm will show 06:00 although it is 1 1/4 day which is 01/01/1900 06:00:00. To see hours from multiple days the format [h]:mm can be used. For example 1.25 formatted using [h]:mm will show 30:00 which is 1 day (24:00) + 1/4 day (06:00).
Although Excel will do this independent of locale settings, the user defined format codes used and the kind of input values which Excel will take as time values are dependent of locale settings.
For example with your locale Danish (Greenland) the format codes are different. See Formatere tal som datoer eller klokkeslæt .
So your format code will be [t]:mm instead of [h]:mm.
And also with your locale Danish (Greenland) the time separator is . instead of :. So values which Excel will take as time values are 123.45 (123 hours, 45 minutes) instead of 123:45.
In your last comment you say: "whereafter it weirdly looked the same, such as: 123:45 and not 123.45". Yes that is because your user defined format [t]:mm contains the time separator : also. But that is different from your locale settings where . is the time separator. While inputting values Excel respects the locale settings and so expects 123.45 as time value for 123 hours and 45 minutes. But after the input Excel applies the cell formatting [t]:mm and so shows 123:45.
In your last comment you say that it confuses you that 17:24 * 24 equals 417:36. But that is exactly what it should.
17:24 is 17 hours and 24 minutes. That multiplied by 24 is 17 hours * 24 = 408 hours and 24 minutes * 24 = 576 minutes. 576 minutes are 9 hours and 36 minutes. So we get (408 hours + 9 hours) and 36 minutes = 417 hours and 36 minutes = 417:36.
I cannot edit the sheet so I copied it. As you can see in column AS and row 43, Google provides 'duration' format. You don't have to manipulate something. Just change the cell format.
In Excel, duration format is [h]:mm. Hit ctrl + 1 at the cell and choose Custom and type [h]:mm at Type and hit enter.
If SO answer is too difficult to follow, try this.
I apologize in advance for how rough this is, but I mostly slapped this code together to fit the task and didn't want to waste time on it. The principles are there though, so at the least it should point you in the direction you need to be heading.
Sub Time_Summarization()
Dim i As Long
Dim j As Long
Dim cell As Range
Dim sHolder As String
Dim vHolder As Variant
Dim arrHolder() As Double
Dim bAdd As Boolean
Dim dHolder_Whole As Double
Dim dHolder_Remainder As Double
Dim sOutput As String
ReDim arrHolder(0 To 2)
' Use a set range. Selection here is just for testing
' Ideally there should be data validation in this loop to ensure that the input
' values are numeric time values.
For Each cell In Selection
' Convert the cell value to a date to permit splitting.
' The value is then split into a 1-d array with 3 positions (H, M, S)
vHolder = Split(CDate(cell.value), ":")
' Loop through the split values from first to last, and trim off the AM/PM.
' If it is a PM date, set the flag to add 12 (13:00:00 gets displayed as 1:00:00 PM)
For j = LBound(vHolder) To UBound(vHolder)
' If PM, set the flag.
If InStr(vHolder(j), "PM") Then bAdd = True
' Remove "AM" and "PM"
vHolder(j) = Replace(vHolder(j), " AM", vbNullString)
vHolder(j) = Replace(vHolder(j), " PM", vbNullString)
' Add the values into the array in the same order.
arrHolder(j) = arrHolder(j) + vHolder(j)
Next
' Add 12 hours if needed
If bAdd Then arrHolder(0) = arrHolder(0) + 12
' Reset the flag for the next loop
bAdd = False
Next
' Step backwards through the array to round up increments of 60.
For i = UBound(arrHolder) To LBound(arrHolder) + 1 Step -1
' This will return the number of times the value goes into 60.
dHolder_Whole = arrHolder(i) \ 60
' This will return the remainder of the value divided by 60.
dHolder_Remainder = arrHolder(i) Mod 60
' Round up seconds to minutes, and minutes to hours.
arrHolder(i - 1) = arrHolder(i - 1) + dHolder_Whole
' Overwrite the remainder
arrHolder(i) = dHolder_Remainder
Next
' Combine the separate values into a string.
sHolder = arrHolder(0) & ":" & arrHolder(1) & ":" & arrHolder(2)
' Just for testing, do with the values whatever you wish.
Debug.Print sHolder
End Sub
Again, this is mostly a model that will work, but will need to be adapted to suit your needs.
Zeth, I downloaded your file and I can make some calculation with your time data. I juss selected all cell with time duration and change the format of cell to "time". Seemingly you should change all cells format, incluiding the empty cells.
If it does not work, find the "More format of numbers" ate the "Numbers" menu. Then, select the option "Hour" and chose the format closest to the format of your data. Also pay attenction to the option "locality" at the bottom of this menu. The option of hour format deppends on the region selected. (Each region in the world have some convenctions about it and Excel reconize much of then.
Formatting the numbers does not change the way Excel does calculations.
So a cell (c3) formatted as time and showing 01:28:00 actually contains 0.061111 because Excel treats time as fractions of a 24 hour day.
When you add up a lot of times and they add up to more than 24 hours the underlying number is more than 1 day so you get number of days before the decimal point and after the decimal point is the fraction of 24 hours remaining. So to convert a duration or time to hours you just multiply it by 24 and format it as a number or general (and the numbers after the decimal point are fractions of an hour). If you just want to format the result as hours and minutes use a format of [h]:mm and do not multiply by 24 - on your system look at Format Cells - Custom to see what the equivalent of [h:mm] is.
I have a two dates in excel "1/2/2016 01:56:05" and "8/3/2016 06:21:46". How do I calculate the time difference between them in a format of days and hours?
Thanks!
Try this to include the spelled out hours and minutes:
=INT(A2-A1) & " days, " & TEXT(A2-A1,"h "" hours, ""m "" minutes""")
Note that since the m comes immediately (ignoring the separator text in quotes) after the h it will be interpreted as minutes and not months
I prefer to work with dates as decimals. It looks cumbersome, but I'm much happier knowing what it's doing.
What I would usually do is to have A1-A2 in cell A3, then work out the component parts separately:
Days: =INT(A3)
Hours: =INT((A3-INT(A3))*24)
Minutes: =INT(((A3*24)-INT(A3*24))*60)
Or if you wanted to do it all in one formula:
=INT(A3)&" days, "&INT((A3-INT(A3))*24)&" hours, "&INT(((A3*24)-INT(A3*24))*60)&" min"
or without using A3
=INT(A1-A2)&" days, "&INT(((A1-A2)-INT(A1-A2))*24)&" hours, "&INT((((A1-A2)*24)-INT((A1-A2)*24))*60)&" min"
It's not the prettiest or most efficient method but you can see how the times are calculated this way.
Assuming the dates are in cells A1 and A2, this will produce an answer with minutes as well in d:hh:mm format.
=INT(A2-A1) & ":" & TEXT(A2-A1,"hh:mm")
Drop the :mm if you don't need minutes.
If you want text:
=INT(A2-A1) & " days, " & TEXT(A2-A1,"h") & " hours"
If you want text with minutes:
=INT(A2-A1) & " days, " & TEXT(A2-A1,"h"" hours, ""m"" minutes""")
Using double quotes alongside each other "escapes" the quote itself and allows the extra text to appear in the string. As Ron stated in his answer, the m following an h in the same format string indicates minutes, so you can save an extra A2-A1 calculation by putting both in a single format.
This question already has answers here:
Excel Date to String conversion
(10 answers)
Closed 9 years ago.
In Excel i am using following formula :-
="Select Count(1) Into Count1 From TRB_TPOAR Where tpo_id='" & A2 & "' and eta_id=old_eta_id and date_creation=to_date('" & B2 & "','dd/mm/yyyy HH24:MI:SS') and UTL1_EDS_ID='DEI037';
if Count1>0 then
Update TRB_TPOAR Set Eta_id=new_eta_id Where tpo_id='" & A2 & "' and eta_id=old_eta_id and date_creation=to_date('" & B2 & "','dd/mm/yyyy HH24:MI:SS') and UTL1_EDS_ID='DEI037';
DBMS_OUTPUT.PUT_LINE('" & A2 & "' UPDATED');
end if;"
In excel sheet Column B contains datetime information(eg 1/14/2013 12:20:01 PM), But when i apply the formula,it adds some other numeric value.Can anyone help me,what are the changes to make in above formula?
In your case, Excel returns the serila number of the date in referenced cell. To make sure it returns a string dispaying the date in the format you want, use =TEXT(cell, FormatString).
E.g.: TEXT(C2, "dd/mmm/yy")
Bonne chance