How to add a column with the corresponding day? - excel

I want to create data that ranges from 01/01/2004 00:30:00 to 31/12/2004 23:30:00 with time step half hourly. I would like also to add a column with just the corresponding day using excel for example:
01/01/2004 00:30:00 1
01/01/2004 01:00:00 1
01/02/2004 00:30:00 2
31/12/2004 23:30:00 365
I tried to make it but I wonder why from cretin date the time step was changing from:
03/01/2004 **01:30**
03/01/2004 **02:00**
to
03/01/2004 **02:29**
03/01/2004 **02:59**
03/01/2004 03:29
03/01/2004 03:59
Any help?

Assuming your date is in cell A1, the following formula will work:
=INT(A1)-DATE(YEAR(A1),1,0)
The Int removes the time from the date, and then it subtracts December 31st of the previous year to produce the number of days that have passed in the year.

For the step, use formula
=A1+1/48 and copy down.

Related

Excel remove timestamp from date and subtract days

So I have a column say Date1 which has date in datetime stamp. I want to subtract 10 days from Date1 column and keep in another column say Date2. I only want to subtract ten days from date not from datetime.
How to remove the time stamp. Read many solutions online but could not find for excel
Input table
Date1
26-03-2000 21:00:00
25-04-2000 00:00:00
21-03-2000 01:00:00
31-03-2000 13:00:00
05-03-2012 12:00:00
Expected output
Date1 Date2 Date1_no_timestamp
26-03-2000 21:00:00 16-03-2000 26-03-2000
25-04-2000 00:00:00 15-04-2000 25-04-2000
21-03-2000 01:00:00 11-03-2000 21-03-2000
31-03-2000 13:00:00 21-03-2000 31-03-2000
05-03-2012 12:00:00 24-02-2012 05-03-2012 and so on
You could use the TEXT() function.
=TEXT(B2, "DD-MM-YYYY")
Alternatively, as the above solution could cause issue based on timezone formatting, you could remove anything past the first space:
=LEFT(B2, FIND(" ",A2,1)-1)
Place either the following in C2 (assuming those headers exist) and drag down.
You could use:
Method 1:
Date1_no_timestamp:
=TEXT(A2,"dd-mm-yyyy")
Date2:
=TEXT(A2-10,"dd-mm-yyyy")
Method 2
Date1_no_timestamp:
=RIGHT("0"&DAY(A2),2)&"-"&RIGHT("0"&MONTH(A2),2) & "-" & YEAR(A2)
Date2:
=TEXT(DATEVALUE(E2)-10,"dd-mm-yyyy")
Results:
You can also use the INT() and TRUNC() functions:
=INT(A2)
=TRUNC(A2)
Their behavior is identical for positive numbers - the decimal part is sliced off.

Google Sheets or Excel Function to return date based on value

I have this table in Google Sheets (or excel). The year is the two last digit of my code.
Code Duration Months
1 AC-26482-17 60
2 AC-26482-18 30
3
I would like to return the date in this format (If no data, just leave blanks).
Code Duration Months Start Expiration
1 AC-26482-17 60 01/01/2017 01/01/2022
2 AC-26482-18 30 01/01/2018 01/07/2020
3
Is there a way to achieve this?
You mean you want to add the duration in months to the start date? If so, your sample has the wrong expiration date. 30 months added to 1/1/2018 is not June 1st, but July 1st.
The formula in Excel is
=EDATE(C2,B2)
If you also want to calculate the start date from the last two characters of the code, given all dates are in this millennium, then you can use this for the start date:
=DATE(RIGHT(A2,2)+2000,1,1)
edit: To handle blank cells, you can check with IsBlank()
=if(isblank(a2),"",DATE(RIGHT(A2,2)+2000,1,1))
use:
=ARRAYFORMULA(IF(A2:A="",,DATE(IF(RIGHT(A2:A, 2)*1>=40,,20)&RIGHT(A2:A, 2), 1, 1)))
=ARRAYFORMULA(IF(A2:A="",,DATE(YEAR(C2:C), MONTH(C2:C)+B2:B, 1)))

How to split the time between two dates over daily columns

I am in much need of help please.
I have the table below.
It has about 300 rows and columns on the right for each day of the year starting 2015, ending 2019. I only entered a few columns here as an example.
What I need:
A formula to split the time (it can be hours or decimal days, it doesn't matter) between the two days on the left on the columns to the right.
In the rest of the days, which are not included in the period, I need a zero in those columns.
I manually entered the results I need so it can help you understand.
E.g.
On the first row:
The employee has spent
15 hours at destination in the first day of travel,
24 hours in the second day of travel
11:50 hours in the last day of travel.
All the rest of the columns to the right, which are not here, starting 1/4/2015 23:59 should give the result zero.
Thank You!!
Entry Date Exit Date 1/1/2015 23:59 1/2/2015 23:59 1/3/2015 23:59
1/1/15 9:00 1/3/15 11:50 15.00 24.00 11.50
As far as I can tell, it boils down to this
1.0 days 2.0 days 3.0 days 4.0 days
period=p in h/d.d p-(1-(so far)) p-(2-(so far)) p-(3-(so far)) 0
EDIT 2: I've come up with a formula.
NOTE:
This formula assumes existence of a column that specifies 0 hours of work between the "end date/time" column ("B") and first work hour ("D"), so you have it like this:
A B C D E F G H
1 Entry Date Exit Date ZERO 1/1/2015 23:59 1/2/2015 23:59 1/3/2015 23:59 1/4/2015 23:59 1/5/2015 23:59
2 1/1/15 9:00 1/3/2015 11:50 0 0.6243055556 1 0.49375 0 0.00
3
The extra column is there to avoid circular dependencies, since
we must "iteratively" accumulate the hours
The main formula for row 2 from column D being:
=MIN(D1-$A2,MIN(MAX(($B2-$A2) - SUM($C2:C2), 0),1))
Note: semicolons may be needed instead of commas in Excel as delimiters.
Note: the last digit in the formula depends on the unit. Here it is in days decimal. If hours, put 24.
In plain English, for a cell
Calculate sum of hours/days decimal in the range C to wherever - 1
Subtract result from the difference between start and end (total hours)
If less than 0, put 0 (MAX(x, 0))
If more than 1, put 1 (MIN(x, 1))
Choose between the result, or the difference between current date and start time, if it is smaller

Time Length Of Subset

I am using Excel 2010, and have access to PowerPivot.
I am trying to find out how to work out the time each subset lasted.
Here is an example of the data:
Run: Date: Time:
A 31/01/2018 20:00:00
A 31/01/2018 21:00:00
A 31/01/2018 22:00:00
A 31/01/2018 23:00:00
A 01/02/2018 00:00:00
A 01/02/2018 01:00:00
B 04/02/2018 10:00:00
B 04/02/2018 11:00:00
etc.
I want to find out the length of time between the first row and the last row in each different subset, so that the output will be:
Run: Time Taken:
A 05:00:00
B 01:00:00
TIA,
Teuthis
I've managed to answer the question myself, for anyone who has the same issue. Here is a picture of the solved spreadsheet, with the formula in red.
Spreadsheet inc solution
The formula is:
=(LOOKUP(A15,$A$2:$A$9,($B$2:$B$9+$C$2:$C$9)))-((INDEX($B$2:$B$9,MATCH(A15,$A$2:$A$9,0)))+INDEX($C$2:$C$9,MATCH(A15,$A$2:$A$9,0)))
=(LOOKUP(search term,array to search,(date to search in+time to search in)))-((INDEX(date to search in,MATCH(search term,array to search,0)))+INDEX(time to search in,MATCH(search term,array to search,0)))
NOTE:
You will need to make sure that the times are all in hh:mm and not dd/mm/yy hh:mm, otherwise the ones close to midnight will be incorrect.

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

Resources