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
Related
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.
I'm having a strange issue here with Excel. I'm working with a custom datetime format in one column...
9/1/2017 12:02:01 AM
This is cell C2. However, using LEN on this cell gives me this...
1900-01-15 00:00:00
I've tried changing the format to General, or Text, and messing around with some custom datetimes, but it doesn't help. I will get the same answer. My goal here is to use this as an exercise and trim the date and time, putting them in separate columns. This spreadsheet was originally created using Google Sheets, not sure if that might explain it?
UPDATE: Ok, so about 1 minute after posting this I think I figured it out? I used LEN in the column to the left of column C, so B. I had been using column D. For some reason, column B returned the numerical value. Obviously I'm very new to Excel. I didn't think column placement mattered in this case. Why does it?
That's because you have formatted the result to be shown as a date.
Remember, dates are simply really large numbers. So, what has happened here is that you get the correct result from LEN(), but then you have formatted this result to be interpreted as a date.
The date seems to indicate the result was 15. In dates, this is 15 full days from 1900 January 1st.
So, you just have to change the format of that cell from a date, to be a number :)
I have this column in excel. The format is dd/mm/yyyy hh:mm:ss.SSS where SSS is milliseconds.
How can I make calculations such as subtracting two cells from each other? I keep getting an incorrect format error but I cannot find a format that includes date and time with milliseconds.
I am able to change the notation of the DateTime value but not split it into two cells.
Comments up above will suggest the built in test to columns method which works really well. Scotts tip about the third step is imperative. Jeroen's comments is using the DATEVALUE function which can be picky and somewhat dependent on your system settings. There is a third choice of using DATE. Jeroen's formula already does most of the work but needs a little tweaking. The nice part of DATE is it is not picky nor reliant on system settings.
Important tidbit of info. Excel stores dates as an integer with 1 representing 1900/01/01. Time is stored as a decimal which represents percentage of a day. So 0.5 is 12:00 noon. Also 24:00 is not a valid time for excel but will still work with some functions.
The DATE function looks for 3 arguments to be passed to it. Year, month, and day in that order. So it is just a matter of pulling the applicable parts of your timestamp as a string out and placing them in the right location. There is a Similar function for TIME.
Let assume one of your timestamps is located in C3
in D3 you can place the following formula to convert the date from text to an excel date:
=DATE(MID(C3,7,4),MID(C3,4,2),LEFT(C3,2))
In E3 you can place the following formula to convert the time from text to an excel time:
=TIME(MID(C3,12,2),MID(C3,15,2),MID(C4,18,6)
To get the information together its simply D3+E3. however if you want to place the whole formula in one cell and avoide helper columns, the formula would look like:
=DATE(MID(C3,7,4),MID(C3,4,2),LEFT(C3,2))+TIME(MID(C3,12,2),MID(C3,15,2),MID(C4,18,6)
Now that the time in in excel format you can perform operations on it, apply formatting to make it look like you want, and use various excel functions with it.
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.
I have an excel document with about 500 rows.
I need to format all the cells in , let's say, B column from date to text.
This is how it looks like now:
2012-06-15
2012-06-01
2012-06-14
What it looks like when formated to text:
41075
41061
41074
It has come to my understanding that this is a timestamp representing days since 1st januari 1900, right? Anyhow, this is not what I want. I want the value of the field to be exactly what it is but with the column type of text. I've found various solutions for this using functions like this: =TEXT(B1, "yyyy-mm-dd") but that is not reformating the cell, it is extracting a value from one cell, reformat it and represent is as text in another.
The rule I'm after: I want all cells in B column to have the type text without changing the value
Thanks!
If you have a situation where columns A to D are dates of 500 rows you then:
Use the =TEXT(A1, "yyyy-mm-dd") function you describe in cell E1.
Copy this formula 4 columns wide, and 500 rows down.
Then copy and paste values to the preceding cells.
Copy Example:
Output:
You're right, Excel stores dates internally as number of days since January 1st, 1900 (apart from a minor leap year bug).
Thus, I'm afraid you cannot have both:
Either you keep the value e.g. (41075) and simply format it as a date, so it'll be displayed as 2012-06-15 -
Or you convert it to text format - but then you either
Lose the underlying value - if you convert it to the format you wish with a text function as you mentioned
Keep the value (41075), but cannot see the date
If you are typing in the values you can by adding a ' before the values to keep it as text.
e.g.
But depending on the method the third party service uses to import these values this may not work and I bet you will not get around it unless you export it to a text editor and import it again.
Also try to play with diferent types of text for your third party service, e.g. "2012-06-15" as some see the quotes and remove them.