# Excel 2005: Difference between two days, counting hour difference

I've been trying to get this Excel function working correctly, and I've hit a wall. I'm trying to calculate the exact difference in days between two dates, taking the start time into account as well as the start day. Seems like this should be a common need?

Example:

``` Start Date End Date Expected Result9/20/2010 8:00am 9/22/2010 3:00pm 2.3 days```

I'm guessing at the .3, but you get the idea :)
My current formula looks like this:

```=IF(End < NOW(), 0, IF(Start >= NOW(), End-Start+1, End-NOW()))```

It works

 Related to : Excel 2005: Difference between two days, counting hour difference How to get the hour and minutes difference between 2 datetimestamp in Excel? Programming Languages Suppose I have 2 timestamp dates:2/24/2010 1:05:15 AM2/25/2010 4:05:17 AMCan anyone please advise what function should I use in Excel to get the difference in hours and minutes?Thanks. Excel 2005: Difference between two days, counting hour difference Programming Languages I've been trying to get this Excel function working correctly, and I've hit a wall. I'm trying to calculate the exact difference in days between two dates, taking the start time into account as well as the start day. Seems like this should be a common need?Example:``` Start Date End Date Expected Result9/20/2010 8:00am 9/22/2010 3:00pm 2.3 days```I'm guessing at the .3, but you get the idea :)My current formula looks like this:```=IF(End < NOW(), 0, IF(Start >= NOW(), End-Start+1, End-NOW()))```It works How can I calculate the difference in days between two days stored as YYYYMMDD in a query? Programming Languages I am writing a query where I need to calculate the number of days since a date that is stored in the database in the format "YYYYMMDD". Since this is not a Date datatype, I can't use native Date functions. What is the best way (performance-wise, readability-wise, etc.) to perform such a calculation in a SQL query. excel syntax problem for formula... difference in days Programming Languages if I have 2 columns of dates and I want to find the number of days between the days of D2 and C2, what is the syntax for the formula so that the result in column E is x number of days between the two dates Grub2: confusing difference in partition counting and device counting Programming Languages In Karmic, Grub2 will be installed. The successor to the current Grub.Grub2 still has a nasty bug. Partition counting starts at 1. However, device counting starts at 0 (the old method). This difference is very unwise and will cause needless confusion.Counting of partitions and devices should be exactly the same. Both of them should start counting at 1, or both of them should start counting at 0 (old method). No mix.I've filed a Launchpad bug report:https://bugs.launchpad.net/ubuntu/+s...b2/+bug/425421Please feel free to support it there. Maybe there is still time to change this before Karmic arrives. :) Time Difference Split in hour intervals excel vba Programming Languages This one is a thinker! I have the below data set: My goal is to get the time difference and split it into hour intervals. i.e. how much time was spent by each person in each hour as below: So the end result should look like this: Covering the fist scenario is pretty easy: ``````Private Sub CommandButton21_Click() LastRow = Worksheets("Sheet1").Cells(Worksheets("Sheet1").Rows.Count, "A").End(xlUp).Row For MyRow = 2 To LastRow If Format(Worksheets("Sheet1").Range("B" & MyRow).Value, "hh") = Format(Worksheets("Sheet1").Range("C" & MyRow).Value, "hh") Then Set oLookin = Worksheets("Sheet2").UsedRange sLookFor = Worksheets("Sheet1").Range("A" & MyRow) Set oFound = oLookin.Find(What:=sLookFor, LookIn:=xlValues, LookAt:=xlPart, MatchCase:=False) If Not oFound Is Nothing Then Worksheets("Sheet2").Cells(oFound.Row, (Format(Worksheets("Sheet1").Range("B" & MyRow).Value, "hh")) + 1).Value = _ Worksheets("Sheet1").Range("C" & MyRow).Value - Worksheets("Sheet1").Range("B" & MyRow).Value End If End If Next MyRow End Sub `````` However covering the second the third scenarios is where I am find it challenging. How do I go about if the "Time In" hour is not the same as "Time Out". And then how do I split the hours and stop at 00:00:00 as subtracting 00:10:00 from 17:00:09 will give you #############. I have been trying to figure out a solution, even thought of using a class module somehow? But haven't been able to figure it out :( Help and suggestions are highly appreciated.