Separate out the date and time from the column - excel

How do I separate date and time from this 2006-09-02T01:07:59.100 I’ve tried =int(A2) but it gives a value error. Please help.

in the column for Date put this formula: =left(A2,10), for the time: =right(A2,12)

Not sure what your purpose is. Display date and time separately or actually have two different values in different cells.
Excel does not play nice with "T" in the middle of the timestamp. You must remove "T" using a string function. Once you have done that your value will format nicely as a date. INT works for the date part, MOD works for time, format cells accordingly.
If display is the only requirement, put the same value in both cells and use cell formatting -- one for Date, one for Time.

Related

How to convert date in the form ##.##.## to the form ##/##/## in Excel?

Trying to calculate age from date of birth (which is inputted by other users), however when someone enters the date with dots in between (i.e. 13.02.2000) the function doesn't work.
The function I'm using to calculate age is: =(TODAY()-D7)/365.25 Where D7 contains the DoB.
Would like the date in other formats to be changed automatically, without the need for an extra column.
I've tried using Format Cells, however it doesn't work.
One method is to use Data Validation:
Select the cell(s) where the date(s) will be entered
Data-->Validation
Allow Date
Data: between (or anything else that will be ok with various dates)
Insert an appropriate range
You can try the following formula. But note this will work only for normal dates and also for the scenario where a date is entered as text using dots as the delimiter:
=(TODAY()- IF(ISTEXT(D7),VALUE(SUBSTITUTE(D7,".","/")),D7) )/365.25

Excel not properly comparing dates, despite same cell format

I have two date rows. Both are formatted as dates. When I do a logic test to see whether the two dates, excel is not recognizing them as the same.
Here is a screenshot of the cells:
This is to confirm that both cell rows are formatted as date:
This is to confirm that the equality check row is referencing the right cells:
I'm stumped. Does anyone have any idea what's going on here? Thanks
If you have confirmed that both are actually dates, and not text masquerading as dates, then time is most likely the issue. Note that time is represented via the decimal such that .5 equals noon.
Assuming you just want to know if the dates match independent of time you can use
INT(G4) = INT(G6)
If you want to compare just the dates use:
=Floor(G4,1) = Floor(G6,1)
Format can mask the real cell value. Format both cells as General, then you can see the difference.
If a cell stays a "date" when it is formatted as General, then the cell is most likely text, not a date.
When formatted as General, you can clearly see if the number has any decimals, i.e. time on top of the date.

Formula IF time between ranges

Currently using a calculated SharePoint column (uses same excel formulas)
I have a column "SignIn" that shows the date/time of a staff sign-in. I have another column "Late Flag" that will show if they are late or not. There are sometimes multiple sign-ins/outs throughout the day, So I need the formula to only flag them as late between a certain time frame (09:35:00 AM to 10:15:00 AM). I have tried a few different formulas - but they keep producing unexpected results (like they all show as late, when they're not).
For example:
=IF(AND([SignIn]>"9:35:00 AM",[SignIn]<"10:15:00 AM"]),"Late","")
This shows my column setup
I have a date/time column for SignIn, and a single line of text column for Late Flag
Most likely your data is converted to a timevalue and shows as "9:36:00 AM", but when selected the true cell value will be "09:36:00" which is because excel has recognised it as a time and converted it to one. However in your formula "9:35:00 AM" will be a string (text value) which will never match with a time value. To get around this you can use TIMEVALUE( in your formula to convert it like a time like so:
=IF(AND(A1>TIMEVALUE("9:35:00"),A1<TIMEVALUE("10:15:00 AM")),"Late","Not")
Also, it might be possible the time in your cell is actually text, which cannot be compared to any time value to begin with. This complicates things, but not much, just wrap a TIMEVALUE( around that as well:
=IF(AND(TIMEVALUE(A1)>TIMEVALUE("9:35:00"),TIMEVALUE(A1)<TIMEVALUE("10:15:00 AM")),"Late","Not")
Using the formula below to achieve it.
=IF(AND(TIME(HOUR([SignIn]),MINUTE([SignIn]),SECOND([SignIn])) > TIME(9,35,0),TIME(HOUR([SignIn]),MINUTE([SignIn]),SECOND([SignIn]))<TIME(10,15,0)), "Late", "")
More information: TIME function

Excel: Subtracting Dates Without Reference Cells

I want to program a cell to calculate the number of days I have left before I meet a deadline.
I would like to do this without reference cells, unlike this tutorial.
An (incorrectly formatted) example of the kind of formula I want would be:=(3/2/2015-TODAY()), where 3/2/2015 is my deadline. This yields some negative serial number,-42051.00, which yields a #NUM! error when put into the DAY formula.
Any idea how to do this without putting TODAY() and 3/2/2015 into their own reference cells? I would like to use functions to keep these paraments completely embedded in the formula.
Right clock the cell with the answer and reformat it as NUMBER. You want to use the Days function not the date function.
=DATE(2015,3,2)-TODAY() is what you want, but I would recommend doing the date in a separate cell for a number of reasons and using "today()" in the formula.
EDIT: Anyone trying to find midpoints would use the date function in this case.
Also, as a general rule for people trying to subtract dates the two trouble shooting methods you want are
A) Check your format-If you want number of dates, it needs to be set as number, if you want a date, you need it to set as date. If you get a long decimal it means you have it formatted as general OR your expression returns a date value rather than a number value. Refer to my original answer.
B) Reverse your dates. Depending on the function and what you want, you may need to move the dates around.
=DATEDIF(DATEVALUE("03/02/2015"), TODAY(), "d")

Excel #Value error when using DATEVALUE function

In cell A2 I have 7/21/2014 12:44:36 PM
When I use DATEVALUE(LEFT(A2;FIND(" ";A2)-1)) I get the error #VALUE.
When I use LEFT(A2;FIND(" ";A2)-1) I get 7/21/2014.
What do I need do that function DATEVALUE(LEFT(A2;FIND(" ";A2)-1)) to return just the date?
DATEVALUE() is designed to make a Date out of plain text. Your cell is currently a Date/Time, which is a numeric value. I recommend using one of the following solutions to get the date from the cell.
Using DATE()
This is the cleanest option and the method that I would recommend.
=DATE(YEAR(A2),MONTH(A2),DAY(A2))
YEAR() gets the Year value from the cell, MONTH() gets the Month value, and DAY() gets the Day value. The DATE() function takes a Year, Month, and Day value, so by passing them into DATE() we can get the Date value from A2.
Using INT()
If we look at the numeric value of your Date in A2, we see that it is 41841.5309722222. The whole portion of the number (41841.) is the date and the decimal portion (.5309722222) is the time. So if we take INT(A2) to convert this value to an integer, we will lose the decimal portion so that all that remains (41841) is the date. So this is our formula for using INT()
=INT(A2)
The same idea can be accomplished with ROUNDDOWN(A2,0) or =FLOOR.MATH(A2) or =FLOOR(A2,1).
Using DATEVALUE()
While the first solution is the cleanest, there is a way to do this with DATEVALUE() that involves converting the cell into Text first. The TEXT() function takes a value and a format string, so we format the cell value as Text as follows
=TEXT(A2,"yyyy-mm-dd")
And this gives us
2014-07-21
We then pass that result into DATEVALUE()
=DATEVALUE(TEXT(A2,"yyyy-mm-dd"))
You will need to format the result as a date.
Using LEFT() and DATEVALUE()
Based on this Stackoverflow question that I found, it appears the issue could be a result of inconsistent formatting, so you might try this solution
=DATEVALUE(LEFT(A2,FIND(" ",A2)-1))
I have included my results with this and the other methods in a screenshot below. You can see by my use of the TYPE() command below the value that I tested this on both a number and text.
Results
Formatting
I'm assuming you want just the date for calculation purposes, but if you just want to display the date, you can format the cell to only show the date and ignore the time element although the time element will still be present in the cell. I'm assuming you know about this, but since you didn't specify, it is a possible solution.
Please try:
=INT(A2)
and format the result to suit.
In a comment I have just seen you mention "=INT(A2) return #VALUE!" so I would suggest selecting your date cells, DATA > Data Tools, - Text to Columns, Delimited, Delimiters Tab (only), and at Step 3 of 3 choose MDY for Date: or change your locale to say USA.
If neither work try =INT(TRIM(A2)) in case you have leading spaces (though not showing them).
If still not working, try applying =CLEAN.
If still nothing works then some further details of where your dates are coming from and how imported would be helpful, and of your locale and default date format.
Date macros are depending on the system date format and based on configured system date format the macros can fail to work. Try below solution. We faced similar issue after open excel file sent by me on another laptop where system date/time format was different. On destination laptop formulas using date functions started giving error. After following below steps errors disappeared.
Left click on bottom right portion of task bar where time is displayed
Click on date and time settings
Click on change date and time
Change calendar settings
Click on reset to go back to original values
Click on OK on all opened dialogues
Now excel formula error should disappear
SIMPLE SOLUTION - I found a solve that worked very well:
=DATEVALUE(TEXT([CELL],"MM/DD/YYYY")
Effectively this lets me convert any value into text, then back into date. It fixed my Datevalue error and I can use it regardless of the original cell formatting.

Resources