Set 00:00 as the last timestamp in Excel - excel

I have a feed of 30 minutes meter readings from MySQL to Excel sorted by the first column which is a datetime format, i.e 10-06-2015 00:00:00, 10-06-2015 00:30:00, 10-06-2015 01:00:00 etc.
Because the reading from 00:00:00 each day is actually data from the last 30 minutes of the day, I need the 00:00:00 reading to be the last row for the day rather than the first (as Excel is sorting by time order 00:00 is the default start of each day). Does anyone know how to format this in Excel so that the 10-06-2015 00:00:00 will come after the 10-06-2015 11:30:00 row and not after the 09-06-2015 11:30:00 row?

I don't think you are going to find a way to do that using just formats. Reason being that the format doesn't change the underlying value, which is what excel uses to do the sort in the first place.
I would suggest using a helper column in which you use a formula... maybe something like this:
=IF(A2-ROUNDDOWN(A2,0)=0,A2+0.99999,A2)
Where the first value of your time series is in A1... then copy the formula down and sort on the column B. This worked for me.

Related

Excel - Placing values that fall within a certain time range

I have the following data on duration of particular services.
A B C D
Usage Start (Local time) Start Time Usage Until (Local time) End Time
03.03.2018 10:00 12:00:00 AM 03.03.2018 00:00 1:00:00 AM
03.03.2018 00:00 1:00:00 AM 03.03.2018 00:00 2:00:00 AM
03.03.2018 16:30 1:00:00 AM 03.03.2018 00:00 3:00:00 AM
And I want to count the number of times a timing falls within a certain range(eg. 00:00 - 01:00)
Start End Counts
00:00 01:00 1
01:00 02:00 2
02:00 03:00 1
03:00 04:00
04:00 05:00
05:00 06:00
What formula should I use and how do I apply it?
I have tried this
=COUNTIFS($B$2:$B$566,">="&A2,$D$2:$D$566,"<"&B2)
And this
=SUMPRODUCT(($B$2:$B$566>= A2)*($D$2:$D$566< B2))
But it doesn't account for more than 24 hour duration (Eg.3/3/2018 1:00 PM - 4/3/2018 2:00 PM, 25 hours)
It looks like you're ignoring the time portion in Columns A and C. Assuming your start/end hour bins are in columns F and G, the formula below will give you the number of times that an event passed through your first hour bin (you have to enter it as an array formula--ctrl+shift+enter). Fill down for subsequent hour bins.
=SUM(($B$2:$B$4<F2+TIME(0,30,0))+($D$2:$D$4>F2+TIME(0,30,0))+INT($C$2:$C$4)-INT($A$2:$A$4)-1)
This will count an event in an hour bin if the event is active at the half-hour mark.
If the event needs to cover the entire time bin, use this formula (again with ctrl+shift+enter):
=SUM(($B$2:$B$4<=F2)+IF(G2>F2,($D$2:$D$4>=G2))+INT($C$2:$C$4)-INT($A$2:$A$4)-1)
Was a bit more complicated than I expected, but I got it to work.
Though before we start, you need to format your table a little. You
can't have date and time in the same cell (as excel has trouble
recognizing storing two formats in 1 cell).
Instead format your table
like so:
Next we should create some hidden rows (technically you can stick what I'm about to do in 1 giant formula, but for sake of clarity I prefer hidden rows)
First we focus on the time difference in hours. Creating the two following columns
Also, make sure, you set the format in these newly added rows to
number. Technically it will work without it, but it will look
confusing to human eye
In the Time defference we use the following formula
=ABS(F2-C2) * 24
In the overnight h column:
=IF(C2>F2, 24-G2, G2) This is utilized that we properly count with transition dates (eg. 23:00 1/1/18 -> 01:00 2/1/18) we don't want to add the extra 24 hours in this case.
That would be the hours fully working, but we also need to ensure the
formula works, when there's more than one night of difference (eg.
1/1/18 -> 3/1/18)
Next, we add these these two rows
In the date difference column, as the column name suggests
=DATEDIF(A2, D2, "d") * 24
Last but not least, the overnight delta is basically the same principle as overnight h, but with dates instead of hours
So now, if we have hidden the rows, added the following formula to result =H2+I2-J2 we get our sought after table:
Which corresponds with the expected result! :)
EDIT: If you don't want to take hours into cosnideration and only count how many times an interval of 24 hours has expired use the following formula
=IF(C2>F2, DATEDIF(A2, D2, "d")-1, DATEDIF(A2, D2, "d"))
(under presumption c2,f2,a2,d2 are in the columns as in my original table i provided)

Excel - DateTime text to Column

I have multiple rows of datetime data.
For eg:
1/10/2014 10:10
2/3/2015 00:03
12/3/2015 12:03
4/3/2015 08:03
2/3/2015 14:03
6/3/2015 22:03
29/03/15 08:03:40
20/03/15 19:03:25
The first 6 rows seems to have been recognized as DateTime by Excel, whereas the 7th and 8th row seem to be in text format.
I'm not able to perform any datetime calculations on it.
I tried Text to Column, but that doesn't give me the option to keep the Date and Time together.
Please advise.
Use the Text to Columns tool and let the data be split into two columns. In step 3 define the date order as DMY (the order that the source data is in).
Then create a new column where you add the Date and time to get everything back into one column again. Copy, paste values, delete individual date and time columns.
If you cannot change the localization on your PC (or don't want to because it will mess up other things), you can always import this as text and then coerce the data into a date/time based on the known format. I don't know of any date parse function in Excel, so you may have to do it the brute force way:
=DATE(MID(A1,7,2)+2000,MID(A1,4,2),LEFT(A1,2))+TIMEVALUE(RIGHT(A1,8))
Because you have multiple formats on your input, you may actually be forced into this. If you want it to work universally on all dates, a UDF would probably be a good idea.
Excel parsed your date as:
mm/dd/yyyy hh:mm
as Excel Default. You can possibly overwrite that by trying what Teylyn have posted.
For example your 1st date: 1/10/2014 10:10 is interpreted as January 10, 2014 and not October 1, 2014.
What you need to do is identify and standardized your date format first.
Once you've done that, we can help you how to move forward in getting your dates correctly on the cells.

Text to Columns formatting issues with Date/Time

I am trying to figure out if this is an Excel bug or just a formatting issue. So I have a column with a date and time in the format m/d/yyy h:m AM/PM (ie. 10/21/2015 2:21:00 PM), and am trying to split it into two individual columns: one with the date and one with the time. I tried using fixed width first, but ended up using delimited just so I could split it exactly where I wanted.
For some reason when it splits the two up, the actual value for time changes. I will end up with one column with the date and a time of 12am (10/21/2015 12:00 AM) and one column with the initial time minus 12 hours (2:21:00 AM).... Trying to figure out why there is still a time value in the date column and why the time value changes. Ideally I want to have a column with 10/21/2015 and another with 2:21:00 PM.
I've tried changing the format of the initial date/time combination etc. and it keeps on subtracting 12 hours from the initial time when it splits.
Has anybody experienced or heard of similar issues?
I think your question is confusing, for example I tried using fixed width first, but ended up using delimited just so I could split it exactly where I wanted. seems back-to-front, but you have a datetime value for October 21, 2015 14:21 hrs, want that as a date in one column and 02:21:00 PM in the next and your environment is UK style (ie day before month).
IF so Text to Columns may be as confusing as helpful. Format the date column as date (to suit) and the time column as hh:mm:ss AM/PM (or similar) and the following formulae may suit, assuming your datetime value is in A1:
For date: =INT(A1)
For time: =MOD(A1,1)

If Statement to check time in excel

I need to create an if statement to check time in excel. For instance if time is between
00:00:01 to 06:00:00 I give a value of 1
if time is 06:00:01 to 12:00:00 I give a value of 2
if time is 12:00:01 to 18:00:00 I give a value of 3
and if time is 18:00:01 to 00:00:00 I give a value of 4
Any ideas how I should implement this?
Assuming that the time is in cell A1, you could use:
=CEILING(A1/0.25,1)
It worked on some sample data for me:
12:01:03 3
18:19:00 4
00:00:01 1
The above works because dates are actually numbers in Excel, and 1 unit represents 1 day. So naturally, if you divide 1 day by 4, you get what you are looking for.
You can use Excel Worksheet formula like shown below (it reads the system time using function NOW()):
=IF(HOUR(NOW())>18,4,IF(HOUR(NOW())>12,3,IF(HOUR(NOW())>6,2,1)))
If HOUR is already given in, for e.g., column A1, then use a simplified formula:
=IF(A1>18,4,IF(A1>12,3,IF(A1>6,2,1)))
Try this
=TEXT(IF(INT(TEXT(A1,"[m]"))<=360,1,IF(INT(TEXT(A1,"[m]"))<=720,2,IF(INT(TEXT(A1,"[m]"))<=1080,3,IF(INT(TEXT(A1,"[m]"))<=1440,4,"")))),"#")

Formula to turn dates into 12 hour categories

I've got some data from a database that lists dates in the following format:
3/2/13 0:09
3/1/13 20:12
3/1/13 3:02
3/1/13 0:45
I need to create a column in my spreadsheet and put them into 12 hour categories, essentially turning it into this:
3/2/13 0:00
3/1/13 12:00
3/1/13 0:00
3/1/13 0:00
If it's between midnight and 12pm, I want it to say midnight, if it's between 12pm and midnight, I want it to say 12pm. I have over 3500 rows of data spanning 2 weeks of dates, so I'm looking for the proper excel formula to make this happen. I've been playing with conditional "If" formulas, but have yet to get it right. Can someone help?!
Excel stores dates & times internally as numbers where 1.0 equals 1d, 0.5 = 12h. Therefore, you can use a simple rounding trick:
=INT(A1*2)/2

Resources