I am trying to change the date format of my cells in excel to another date format. Currently it is in this format: apr, 10, 2017 01:58:24 PM. I would like to have it in a normal format like dd-mm-yyyy without the time, but I can not get it to work with the formatting in excel.
Thanks in advance,
Kester
You could use this:
=(MID(A2,FIND(",",A2)+2,FIND(",",SUBSTITUTE(A2,",","#",1))-FIND(",",A2)-2)&"-"&LEFT(A2,FIND(",",A2)-1)&"-"&MID(A2,FIND(",",SUBSTITUTE(A2,",","#",1))+2,LEN(A2)))*1
Which is basically a bit of string manipulation (and some substitution of , to # to help) to put it in the generic format 'd-m-y h:m:s t', which excel understands, then multiply the string by 1 to force into a number (in this case 42835.58222); which you only have to format as date (important!):
Edit: Per comments, the first comma doesn't actually exist, so the revised formula:
=(MID(A2,FIND(" ",A2)+1,FIND(",",A2)-FIND(" ",A2)-1)&"-"&LEFT(A2,FIND(" ",A2)-1)&"-"&MID(A2,FIND(",",A2)+2,LEN(A2)))*1
With data in A1, in B1 enter:
=DATE(MID(A1,10,4),MATCH(LEFT(A1,3),{"jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"},0),MID(A1,6,2))
and apply desired formatting:
(this results in a genuine Excel date that can be used in sorts, calculations, etc.)(this assumes that the day field is always two digits)(if your month list is in a language other than English, edit the month list)
I've an Excel file (.xlsx) which contains cells with Dates like this: "14/12/2015".
The Dates are calculated with formulaes like this: "=D3+1".
Now I've got a little VBA script which does some things and saves the data to a .csv file... The issue is that all my dates are converted to normal numbers something like this: 41992
How can I stop excel from doing this? Anyone any ideas?
Cheers!
Patrick
Dates in Excel are really just numbers. Use the FORMAT function in your code to convert back to string.
Format(nValue, "yyyy-mm-dd")
No need to do it in VBA, You can do it directly in the cell where you have the formula D3+1
Just use =text(D3+1,"dd/mm/yyyy")
I have a date column with YYYY/MM/DD HH:MM:SS AM/PM format in Excel file(xlsx).
But when I am trying to save it in CSV format then the values in date column converts to MM/DD/YYYY HH:MM .
But I want to keep the values in the same format.
Please help me to solve this and Thanks in advance.
Use Custom format as yyyy/mm/dd hh:mm:ss AM/PM in Type text box and save as csv should work
This is a well known problem with CSVs. You can't provide any sort of formatting information about the column to excel, and so it takes liberties with dates. One way around it is to trick excel into processing the column as a string value, instead of a date value, by wrapping it in ="", so an example csv might look like this:
Sample.csv
Name,Date,Note
Foo,="2014/12/03 12:14:15 AM",Bla
Bar,="2012/11/13 3:14:15 PM",Bla Bla
Excel will preserve the date format because it will process it as a string value, so it will not modify it in any way.
I am getting data in a CSV file with data column having format e.g. 1987-09-17T00:00:00.000-06:00.
When I apply date formatting on it to say DD/MM/YYYY, it doesn't change to 17/09/1987.
Is there a way to achieve this?
Thanks!
Excel will assume it is text because it is not in a format it recognises as being a date. You could use LEFT() and MID() functions to split out the parts you want as arguments in the DATE() function. Eg
=DATE(left(A1,4),(MID(A1,6,2),MID(A1,9,2))
I have tried and change 2014/02/13/19:57:00 to 2014/02/13 19:57:00, but excel still cannot detect this as readable date format so I cannot change to another date format in excel. I have a whole column of date like this one.
So what can I do in excel?
Thanks.
You should be able to use something like this:
=SUBSTITUTE(A1,"/"," ",3)*1
This replaces the 3rd occurrence of / and replaces it with a space. The *1 then tells excel to convert it into a number (if possible). Formatting the result as date time should give you the datetime you are looking for.
If for some reason that doesn't work, this formula can be used instead:
=(DATE(LEFT(A1,4),MID(A1,6,2),MID(A1,9,2))+RIGHT(A1,8))*1
That one takes bits of the date and sticks the time. Again, format the cell as datetime.