I have around 20,000 records in an Excel file and around four columns which have dates. I am trying to insert those into SQL. However date columns have dates in incorrect format eg; 02/092015 or 02/90/2015 or 2015. So checking 20,000 records one by one would be very lengthy.
I tried to count / but it didn't work. It changes the format of column to date.
I was looking for some formula which can check the format and maybe color the cell or something like it.
I was running across this issue today, and would like to add on to what nekomatic started.
Before we begin, the TEXT formula needs to follow the date format we are working with. If your dates are in month/day/year format, then your second argument for the TEXT formula would be "mm/dd/yyyy". If it is in the format day/month/year, then the formula would need to use "dd/mm/yyyy". For the purposes of my answer here, I am going to have my dates in month/day/year format.
Now, let's assume that cell A1 contains the value 12/1/2015, cell A2 contains the value monkey, and cell A3 contains the value 2015. Further, let's assume our minimum acceptable date is December 1st, 2000.
In column B, we will enter the formula
=IF(ISERROR(DATEVALUE(TEXT(A1,"mm/dd/yyyy"))),"not a date",IF(A1 >=DATEVALUE(TEXT("01/01/2000","mm/dd/yyyy")),A1,"not a valid date"))
The above formula will validate correct dates, test against non-date values, incomplete dates, and date values outside of an acceptable minimal value.
Our results in column B should then show 12/1/2015, not a date, and not a valid date.
Two of the examples you give are text which may be identified with Conditional Formatting by applying a formula rule such as:
=ISTEXT(A1)
and colouring the result as you wish. There would be an issue if all your dates (even those of valid format) are also text but I'm guessing that is not the case.
For the third example (ie 2015) a CF formula rule such as:
=AND(A1<2500,A1>0)
may help.
If your columns are a mixture of what should be dates and other entries that are properly text strings your approach may be better than the more general ISTEXT, for example a CF formula rule of:
=FIND("/",A1)>0
If you can add a column to the Excel sheet with the formula
=DATEVALUE(TEXT(A1,"dd/mm/yyyy"))
this should return #VALUE if the contents of A1 are not a valid date in dd/mm/yyyy format. You can filter on this value to identify the incorrect records.
Edit: If A1 contains only 2015 this formula returns 07/07/1905 (if the formula cell is formatted as date) so you can spot these by filtering for dates before the earliest correct date your file should contain.
Related
I want to get days of the month corresponding to each particular dates in a column in Excel (Note that I am using the web version of office Excel).
The formula =TEXT(A2,"dddd") works correctly for the first row and then when applied to the later rows does not perform as needed. It returns the same date and not the weekday. I have checked the format of the cells, and it is all sent to General.
See the attached image for reference, the formula worked in C2, and not after that.
Note: I have inserted a table for the required range.
Not Recognizing d/m/yyyy
For cell A2 you can use this formula instead (in cell C2):
d/m/yyyy (Your Case)
=TEXT(DATE(VALUE(RIGHT(A2,LEN(A2)-FIND("/",A2,4))),VALUE(MID(A2,FIND("/",A2)+1,FIND("/",A2,4)-FIND("/",A2)-1)),VALUE(LEFT(A2,FIND("/",A2)-1))),"dddd")
m/d/yyyy (Someone else might need this.)
=TEXT(DATE(VALUE(RIGHT(A2,LEN(A2)-FIND("/",A2,4))),VALUE(LEFT(A2,FIND("/",A2)-1)),VALUE(MID(A2,FIND("/",A2)+1,FIND("/",A2,4)-FIND("/",A2)-1))),"dddd")
Conditional formatting does not apply to dates less than TODAY(), only greater than TODAY().
I have an IF statement with two VLOOKUPS inside. One of them outputs "Not Registered" if the cell looked is empty. The other, just copy the data that is on the other spreadsheet.
=IF(VLOOKUP($A5,Table,#MATCH(D$3,Headings,0))=0,"Not
Registered",VLOOKUP($A5,Table,#MATCH(D$3,Headings,0)))
Conditional formatting is set to:
cell values >= TODAY() are green
cell values < TODAY() are red
cell values = "Not Registered" are yellow
I suspect the conditional formatting is not reading properly the date. Every date cell is formatted as long date.
The problem comes up because A3 is empty.
Change the rules to use =Today() or populate A3 with the desired date.
Edit 1: If this is not working for you, check the data type of cells that should be red. If these are not real dates (but text), then they will never meet the condition. Make sure that all cells that look like dates actually contain dates (and not text).
If the lookup table stores the dates as text, then you can make the changes there, because the Vlookup will return the same data type.
Edit 2: Selecting a cell and changing its format will NOT convert text to a date. You can test if a date is really a date by changing its format to General. If this results in the cell showing a number, then it's a real date. But if the cell appearance does not change, the value is text and you need a different approach.
One option would be to use a helper column with a formula like =DateValue(A1). Copy the helper cells and paste them as values over the original cells, then format as date.
Or, put a zero into any cell, copy the cell, then select all cells that may or may not be dates and use Paste Special > tick "Add" > OK. That will convert dates stored as text back to their internal storage number. Then format the cells as dates.
Or, do the conversion after the Vlookup by wrapping a DateValue around the VLookup formula.
=DATEVALUE(VLOOKUP("a",A1:B1,2,0))
The "date" in B1 is really text. The Vlookup returns it as text, but the DateValue() then converts it to a date. If this one throws an error, the date text does not agree with your regional settings of what a date is expected to look like.
Reason:
Whenever the cell go past by the Less than today rule, computer will read that as zero so it will return true because zero is less than today.
Solution:
On the Conditional Formatting Rules Manager,try to enable the Stop if true for the not registered rule.
Last Day of Previous month based on cell date given in excel , example used A1 cell as 6/23/2016 …. Have applied formula in b1 cell '=EOMONTH(A1,-1) … output am getting in number format could you please help to get date format here ? Any formula which helps apart from this ? Much appreciated with your responses
The format is applied as follows:
Subtract the day-of-month from whatever date you have.
=a1-day(a1)
Excel tries to carry the primary formatting from the precedent cells in a formula but sometimes it cannot so it defaults to a general number. EOMONTH is often the latter; simple subtraction seems to work.
As you will see in my picture, I do have the following problem: I want to find out whether a value in a cell of column A contains a date or not. In order to do so, I have used the following formula in cells B1:B8:
German Excel formula: =WENN(ISTZAHL(TAG(A1));1;0)
English Excel formula: =IF(ISNUMBER(DAY(A1)),1,0)
As you will quickly notice, it works for B1:B6 but is faulty when it comes to B6:B7, etc.
So: What is wrong with that formula? Column A is formated as TT.MM.JJJJ (or DD.MM.YYYY) as a whole.
If that formula were to work properly, I could easily count the number of dates in column A using column B. But: Is there a way to do this without having to use column B, that is, checking whether a cell in A contains a date and adding it up in one cell with a respective formula?
You need to check if the cell is empty before checking if it's a date:
=IF(A1!='', IF(ISNUMBER(DAY(A1)),1,0), '')
If you want the sum, you can use
=COUNTIF(B16:B23,">32874")
32874 is the decimal representation of 1/1/1900, if you need to parse earlier dates, you can just use 1 too.
I'd like to assign dates to cells in a planner spreadsheet I have made.
Currently, the rows are months, the columns are days of the week, and each individual cells just have a number for the day of the month.
I don't want to display the full date in the cell, just have the cell "know" what date it is representing. One use of this could be to have the current day always highlighted in a different colour when opening the spreadsheet. Is this possible in Excel?
Looking at your question, the results would require to show multiple "dates" within the cell.
For January '16 for example, you would have 4 different type of dates as January has 4 Mondays (4;11;18;25). Is this what you're looking to achieve? Otherwise it is not possible to have excel figure out a single date unless you provide it with additional references in order to come up with a result.
Enter a date into a cell. Format the cell to show the part of the date you want to see. In the screenshot, column A contains full dates in each cell. A2 and down are formatted with the custom format code shown in column C
Excel still treats the dates as the underlying full dates in formulas, even though only parts of the dates are showing in the cell.