Hopefully this is a better phrased question... Ultimately what I'm trying to do is figure out if someone is late or not. So I have their shift start times... it's in a string format of XXX-####, e.i. Sun-0320. I also have a timestamp(Macro) of when they clocked in same format as Now()
So currently I have it as
A1 = Now()
B1 = Right(F1,4)
F1 = ShiftCode
C1 = A1-B1
A1 and B1 are both formatted to custom time of hh:mm
C1 is formatted as numbers. i tried time also
The NOW() function returns both the date and time, which changes as your cell/worksheet/workbook is being updated.
https://support.microsoft.com/en-us/office/now-function-3337fd29-145a-4347-b2e6-20c904739c46
There is a lot of options to add or subtract the time in excel, like here:
https://superuser.com/questions/89045/how-to-get-time-difference-as-minutes-in-excel
https://support.microsoft.com/en-us/office/calculate-the-difference-between-two-times-e1c78778-749b-49a3-b13e-737715505ff6
https://www.ablebits.com/office-addins-blog/2015/06/24/calculate-time-excel/
https://www.excel-easy.com/examples/time-difference.html
https://exceljet.net/formula/calculate-number-of-hours-between-two-times
but regarding your case I would rather use something like this:
instead of
=NOW()
expand the formula, by adding another TEXT function and defining the time units for it:
=TEXT(NOW(),"hh:mm:ss")
Then if you have another cell with a time value, you can easily add or subtract from the cell defined by the aforementioned formula.
I have following formula which i add as a picture here in the question as well.
=MIN(INDIRECT(ADDRESS(ROW(AF4);COLUMN(AF4))&":af"& (MIN(IF(A4:A108="";ROW(A4:A108))))))
AF3 and AG3 columns should calculate the minimum date in dynamic range(based on empty cell in A). As you can see in AF, if all values are "N/A" formula brings automatically 00.01.1900 by default. I want it to return empty string if the range does not contain any date. If it has a date inside the range, the formula should work as it works in AG3.
How can i do this?
Wrap the formula in IF like below and test:
=IF(MIN(AF4:INDEX(AF:AF,MIN(IF(A4:A108="",ROW(A4:A108)))))=0,"",MIN(AF4:INDEX(AF:AF,MIN(IF(A4:A108="",ROW(A4:A108))))))
I have dropped INDIRECT which is volatile. Above construct is less volatile.
It is ARRAY formula so you need to CTRL+SHIFT+ENTER.
Make sure you replace "," with ";" in formula arguments at your end.
You could follow #shrivallabha redij's suggestion of a custom format or use a TEXT statement like this
=TEXT(MIN(INDIRECT(ADDRESS(ROW(AF4),COLUMN(AF4))&":af"& (MIN(IF(A4:A108="",ROW(A4:A108)))))),"dd.mm.yyyy;;")
EDIT
I agree with #shrivallabha's advice to use Index instead of Indirect. If I was doing this from scratch, I would also use Aggregate:
=IFERROR(AGGREGATE(15,6,AF4:INDEX(AF4:AF108,AGGREGATE(15,6,ROW(A4:A108)/(A4:A108=""),1)),1),"")
I'm looking to return the start and end dates of a person availability based upon a gantt chart of their hours on a project.
I can at the minute only return the start of their availability, essentially my formula is looking left to right and returning the date of the first "0" cell it meets.
I need the formula to look right to left and return the date of the cell of the last "0" it meets.
Formula currently is:
=IFERROR(OFFSET(B3,(ROW(B3)-2)*-1,MATCH(0,C3:O3,0)),"")
This formula will return the results you're after:
{=INDEX($C$2:$S4,1,MAX(IF($C4:$S4>0,COLUMN($C4:$S4),0)))}
Enter as an array/CSE formula (use Ctrl+Shift+Enter to complete the formula - this will put the curly brackets in).
NB: It will return 00/01/1900 if the last date is greater than 0.
Adding this custom format to the result cells will hide the 00/01/1900: dd/mm/yyyy;;;
I used this to reference to get the answer:
http://www.mrexcel.com/forum/excel-questions/234469-find-last-value-row-greater-than-zero.html
I found the answer by using the formula above and the link provided. My data set was different to the sample one shown. Hence the cell references are different.
=(OFFSET(A3,(ROW(A3)-2)*-1,LOOKUP(9.999999999999E+307,IF(AA3:CP3>0,COLUMN(AA3:CP3)))))
I have a cell that has the formula =INDIRECT(CHAR(COLUMN()+65)&ROW())*MONTH($A$1)/12 where INDIRECT references an integer and $A$1 is a date. For some reason, the MONTH part converts the entire cell into a date instead of a number. How do I change the formula to have it return a number in number format? (Manually changing each cell through the ribbon is not an option for me).
I haven't tested this (and I can't comment till I get 50 rep), but you could wrap the whole thing in a text formula, then multiply by 1:
=TEXT(INDIRECT(CHAR(COLUMN()+65)&ROW())*MONTH($A$1)/12,"#")*1
Hope this helps!
Short story short:
I want to check the cell C21 if it contains a date. I can't use VB cause it's deactivated by GPO.
Used this from this page
D21 contains this:
=WENN(ISTZAHL(DATWERT(C21));"date";"no date")
in english
=IF(ISNUMBER(DATEVALUE(C21))...
C21 this:
=HEUTE() # in english: =TODAY() Maybe other dates later, but allways in the correct format
but it allways returns "no date"
Use this: =IF(LEFT(CELL("format",C21))="D",..,..). Learn more about CELL formula here.
In your example =TODAY() already a real date and not a date stored as text, so doesn't make too much sense to use DATEVALUE there.
Update
Here are some example dates and how CELL recognize them:
format value output
dd/mmmm/yyyy 12/June/2015 D1
dd/mm/yyyy 12/06/2015 D1
yyyy 2015 G
general 2015 G
dd/mm 12/06 D2
mmmm June G
dd mmmm yyyy 12 June 2015 G
Note: CELL is not volatile, so if the format of source cell is changed it won't be refreshed automatically, you need to either recalculate your sheet / book, either open the formula and press enter (also automatice recalculation initiated by any other volatile formula will cause it to refresh).
Use this formula, the expression will return TRUE if cell A1 contains an invalid date.
=ISERROR(DATE(DAY(A1),MONTH(A1),YEAR(A1)))
This formula works by evaluating each component part of the date: DAY, MONTH and YEAR and then aggregating them using the DATE function.
ISERROR will the catch any errors by returning TRUE (invalid) otherwise FALSE (valid).
Obviously the date value in cell (A1) must contain values >= 01/01/1900.
Useful for "Conditional Formatting".
Excel stores dates as numbers. 1 is 1-Jan-1900.
When it comes to numbers in a cell, Excel cannot tell if a number is meant to be a number or a date.
Today is 11/06/2015 as a date and 42166 as a number. For the consumer of a spreadsheet, the cell can be formatted to display the number as any number format or as a date. Excel formulas cannot tell whether the number in that cell is "meant" to be a date.
So, there is no Excel formula that you can use in a spreadsheet that will tell you if cell A1 is about 42166 widgets or if contains the date of June-11-2015.
Some of provided answers, checks cell format, which will not considers cell value, as you can format differently each cell no matter of its content, for checking if a cell value is date you can use this:
if(ISERROR(VALUE(c21)),"No Date", ----do staff for Date ----)
or shorter version which just will inform you "no date" status. If a date entry is find, it will return its numerical value instead:
IFERROR(VALUE(c21),"No Date")
hope this helps,
Cheers,
M
use the following formula ...
=IF(NOT(ISERROR(DATEVALUE(TEXT(C21,"mm/dd/yyyy")))),"valid date","invalid date")
I think it will solve your problem.
If the value is a string this method would work.
TEXT(DATE(VALUE(RIGHT(AI8,4)),VALUE(MID(TRIM(AI8),4,2)),VALUE(LEFT(AI8,2))),"dd.mm.yyyy") = AI8
Just wanted to add to the discussion that although you can check with a date(year;month;day) it will give you false positives, since the way it works is that it seems to just roll over values that exceed the logical limit, i.e. if you have the date 99-12-35 it will assume that you meant to write Jan 4th 2000, since that is the 35 - the 31 days of December. In other words, you will find some errors, but not all. Same goes for months exceeding 12.
try this formula (depends on date format):
=IF(DATE(TEXT(C21;"yyyy");TEXT(C21;"mm");TEXT(C21;"dd"));"contains date";"doesn't")
I tried every solution posted but none of them work if there are empty cells in the date cells, so I added a check to GBGOLC's answer and now it works with empty cells:
=IF(NOT(OR(ISBLANK(C21),ISERR(DATE(DAY(C21),MONTH(C21),YEAR(C21))))),"Yes it is a date","Not a date")