Excel convert dates from different formats - excel

I have a data set with column A containing different date formats, the column format is date:
I would like to have all entries in the format dd-mm-yyyy, and one formula for the whole column.
With format cells, I could not get them into the same format.
I tried TEXT(A3, "dd-mm-yyyy"), but this does not do anything.
DATEVALUE(A3) gives me an error.
Is there a simple solution to this?

Given that Excel cannot parse the date before 01-01-1900 you'd need a proper date and then select your range, and go Data>Text to Columns.
Here, select Delimited and click Next. Deselect all options (usually only Tab is selected) and click Next. Select Date option and choose the format which seems to be DMY in your case.
Then you can use the formula such as:
=TEXT(A3,"dd-mm-yyyy")

Related

Extracting substr and concat In Excel not working as it should

So I have an excel file which has a date column in the format mm/dd/yyyy Like in this picture:
I want it in the format dd/mm/yyyy and i tried formatting the cells but they dont change. at last I chose to simply extract and concat the dates in a new column but it works for some cells while with others not.. this is the result:
As you can see sometimes it works and sometimes not. this is the formula I used (please bear in mind I am just starting out with excel and I have no clue of tricks or other methods) :
what is causing the faulty results in some of the cells ? TIA
Edit: Link for the data https://data.world/markbradbourne/rwfd-real-world-fake-data/workspace/file?filename=Call+Center.csv
If they are true date then can use-
=TEXT(A2,"dd/mm/yyyy")
If they are date format stored as text then can try-
=TEXT(DATEVALUE(A2),"dd/mm/yyyy")
If you need to extract strings then concat and convert to dates then try-
=DATE(RIGHT(A2,4),LEFT(A2,2),MID(A2,4,2))
You should use the DATE formula and then format as you need
=TEXT(DATE(RIGHT(E2,4),MID(E2,4,2),LEFT(E2,2)),"dd/MM/YYYY")
DATE formula takes Year, Month, Day as parameter - and converts that into a valid date.
TEXT then does the formatting for the output
Perhaps you should first try in using Text To Columns which in built in Excel, Under Data Tab, Grouped under Data Tools,
So just select those range, Goto Data Tab --> Click On Text To Columns --> Then select Delimited in the First Step --> Next --> Next as well in the Second Step --> and in the Third Step click on Date and change it to MDY and change the destination to adjacent cell and press Finish.
Since Dates & Times are stored as Numbers in Excel hence it will return you as numbers therefore you just need to format it as dd/mm/yyyy by pressing CTRL 1 --> Format Cells dialog opens --> under Number Tab --> Click on Custom and type by removing the General --> dd/mm/yyyy.
Using TEXTJOIN() & MID() Functions, assuming you are using either Excel 2019/2021 or MS365
• Formula used in cell B2
=TEXTJOIN("/",,MID(A2,{4,1,7},{2,2,4}))+0

Date validation in MM/DD/YYYY format in excel column?

I am trying to validate an excel column having date field of DD/MM/YYYY format.It's an existing column , I want to color/differentiate cells having wrong values.
It should always be in DD/MM/YYYY format.
It should validate data also. like 29/02/2017 should mark as wrong entry. similarly 31/04/2018 is wrong entry.
I don't know if there is any easy way of validation of both structure and data in excel for already defined excel fields. Any help?
If you have dates in range A2:A10 then select the first cell, A2. From the Home tab, use Conditional Formatting, Manage Rules, New Rule. Under use formula enter =ISERR(DAY(A2)). Use Format to set the cell formatting, then select OK. Then in the Conditional Formatting Rules Manager, modify the range under Applies to $A2:$A10. This will highlight all the none dates.
I see two ways of accomplishing this task.
The first method would be to do conditional formatting as you have requested with this formula.
=IF(AND(NOT(ISERR(DAY(A2))), CELL("Format", A2)="D1"),TRUE, FALSE)
The second method could be used, but doesn't require the use of conditional formatting instead it using Data Validations. Data Validations won't change the color of a cell, but it will prevent you from inserting a invalid date.
Format the Cell 'Number' to a category type of 'Custom' and then the type should read - 'dd/mm/yyyy'
Now, add 'Data Validation' to the cells in question. The 'Data Validation' should be the following
Allow: 'Date'
Data: 'greater than'
Start Date: '01/01/1900'
Once you have done this, all of the dates will still need to be TYPED as 'mm/dd/yyyy' but as soon as your press 'enter' then the format will change it over to 'dd/mm/yyyy'

AutoFill not picking up my date pattern

I'm tyring to create a time series in the format of yyyy-mm (e.g 1950-01:1950-12) for the period 1950-2016.
I have changed the cell format to this custom setting but still when I try and drag down to autofill the next date after xxxx-12 is xxxx-13 instead of 01.
Can anybody advise me on how to get excel to recognize this pattern please?
Select the cells you want to format.
Press CTRL+1.
In the Format Cells box, click the number tab.
In the Category list, click custom, and then under Type, type the date format that you want

how to format time from HH:MM:SS to HHMM in excel?

I have an excel sheet in which one of the column is transaction time and its format is HH:MM:SS. But I need transaction time in HHMM format so that i can upload that excel sheet into my application. As of now i am manually formatting each row, is there any way i can apply required format to whole column at once?
If for your eyes only:
select whole column, right click somewhere in your selection, go to Format Cells, tab Number, Catergory Custom.
Type HHmm
Press OK
done.
If you need this as the actual value:
make a column containing the following formula =TEXT(<targetcell>;"HHmm")
Note that it is language-dependant whether you need a , or ; in that formula.
You have two options:
Custom format the field.
Use a function in another cell. Suppose, cell A1 contains the text 15:48:58. You use the formula in another cell (say B1) as =TEXT(HOUR(A1),"00")&TEXT(MINUTE(A1),"00"). This gives the output as 1548.
For example, type .633 in B2 cell. When we convert 0.633 to time means we convert 0.633day. We consider 24 hours as 1 day.
Follow the steps:
Select B2 cell and right click.
From shortcut menu, go to Format cells. Format cells dialog box appears.
In the dialog box. click custom under Category list. Find hh:mm:ss from right list.
Now edit it as hhmmss in the right side just under 'Type:'.
You may read this tutorial from msofficeworld: Format Time in Excel

Excel, change format of a date, then make ALL cells in column look the new way

I have a file where the date column is in a format I cannot make calculations, so I changed the column to another format where I can subtract dates. As usually happens with excel though, only when I double click an entry it changes to the new format.
Does anyone know how I can force all the cells in column to change to the new format, in order for my script to be able to subtract dates for the whole file?
Here is a really easy work-around:
Insert a blank column.
Change the format of the blank column to the date format that you want.
Copy the column with the dates that won't format.
Right-click on the first cell of the blank, formatted column, select Paste Special, select Paste:Values and Operation:Add. (Because the destination cells are blank, the dates will be unchanged.) Click OK.
The dates will now appear as dates.
Try this in your vbScript
objExcel.Cells(Row, Column).NumberFormat = "#0.00"
If you just want to do this via VBA, you can use something like this:
Range("C1:C100").NumberFormat = Range("B2").NumberFormat
The example above just changes the format for cells C1-C100 to whatever the format is in B2.
Update:
I noticed you said that the format is working fine, but dispalys as #######. This typically happens when the column is not wide enough to show the whole value, so resizing it manually or using something like the belwo should fix your issue:
Columns("C:C").EntireColumn.AutoFit
You may also want to try =Datevalue() in an adjacent column. My experience in these types of situation is that Excel doesn't understand that your entries are dates. They are text, and will not change to date simply on a format change. Alternatively you can try text to columns to do the conversion.

Resources