I have not done excel programming. I have a table as follows:
Excel Part
CreatedTime Id
05/04/2015 1000
05/10/2015 1000
05/12/2015 1000
05/01/2015 1001
05/05/2015 1001
05/03/2015 1002
05/13/2015 1002
What I want is:
CreatedTime Id Days_Between_Actions
05/04/2015 1000 4
05/10/2015 1000 6
05/12/2015 1000 2
05/01/2015 1001 1
05/05/2015 1001 4
05/03/2015 1002 3
05/13/2015 1002 10
This formula works for entries corresponding to every 'Id' except the first entry of each 'Id' -> =IF(A3 = "05/01/2015",1,DAYS(A3,A2))
. But for the first entry corresponding to every 'Id' the formula has to be =IF(A2 = "05/01/2015",1,DAYS(A2,"05/01/2015")+1)
.
- Is an easier way to do this?
- I currently have to use one formula for the first entry and another formula for other entries corresponding to an 'Id' and this makes it very difficult to propagate this for the entire table. Is there a single formula I can use?
SQL Part
I'm using a query like -> select distinct convert (date, CreatedTime) as CreatedTime, Id from database.table where createdtime between '2015-05-01 00:00:00' and '2015-05-15 23:59:59' order by Id, CreatedTime
- So, is there an easier way to get what I want by changing the query?