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)
Related
I need to convert a date format into a date format that excel understands. This format I'm using is an export from a military system that spits the date out in a "military style" date format.
I need this: 011000Z OCT20 to equal 01-OCT-20.
The original format is this: DD HHMM(time Zone) MMM YY; so 01 1000Z(GMT Time) OCT 20
How can I make Excel recognize this as a date?
Currently, I'm using the Text to column feature to separate out the date, dump the time, then concatenate the multiple column into a date format. I then have to copy paste the new text into a date formatted column.
I have over 300 rows of date to go through, and its usually 100 rows weekly.
MACROS are not allowed on my systems. So this will have to be formulas.
Just looking for a more automated / simplified method that can keep up with the system exports.
Thanks everyone!!
Frank
If one has TEXTJOIN:
=--TEXTJOIN("-",TRUE,FILTERXML("<a><b>"&SUBSTITUTE(A1," ","</b><b>")&"</b></a>","//b["&{1,4,5}&"]"))
Depending on one's version this may require the formula to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.
then format the cell: dd-mmm-yy
=--REPLACE(A1,3,5,"")
will remove the time portion and convert to a date.
You'll need to format the result as a date
I have a date field where the format is (example) 20170101.
When I try to convert this field to short date, it comes up as "###".
I need the date in the format of 1/1/2017.
Can someone help?
Thanks!
The data is not a date but a number and by simply changing the format will try to return a date that is 20,170,101 days from 1/1/1900. And Excel stops recognizing dates after 12/31/9999. This would be well beyond that, roughly 45 thousand years beyond that.
you can use a helper column with the following formula:
=--REPLACE(REPLACE(A1,7,0,"/"),5,0,"/")
Format it as desired.
Then you can copy paste just the value over the original.
I received excel sheet with dates in column U as (Jul 8, 2009).
I changed cells format to custom date (mmm d, yyyy)
now in column V, I added below if statement
=IF(U9="";"No Date";IF(U9>TODAY();"warranty";"expired"))
my problem is: why all values returned as "warranty" what ever date in column U?
May 10, 2016.....warranty
Jul 8, 2011.........warranty
Jan 1, 2017........warranty
Jul 23, 2011........warranty
You need to turn on the automatic calculation:Options>Formulas>Workbook calculation>Automatic
Or you can turn it on in the formulas tab in the tool bar:
It sounds like the data in the sheet might be wrong - have you checked its value and compared this to the value of today? (use the value function on the cell is probably easiest)
There is a '1904' date setting deep in the bowels of the options (under advanced) which some systems use - whereby the dates started at a different point that Excels usual. This means that today would not match today - and the situation you are describing is possible.
The dates you received might have been formatted as Text. In that case changing the cell format won't convert it to date, and some formulas and expressions will regard it as text and not as a date value.
To verify this try to change the date format on one of the date cells that calculate incorrectly to some other date format or number, and you will see there is no effect.
One solution is to add the DATEVALUE() function to your formula:
=IF(U9="";"No Date";IF(DATEVALUE(U9)>TODAY();"warranty";"expired"))
This will work only if all of your dates are formatted as text.
Another solution is to run Text to Columns from the Data menu. This process has the side-effect of converting data types.
Select your dates column and run Text to Columns.
Choose Delimited and click Next.
Remove any selected Delimiters and click Next.
You may choose General or Date and click Finish.
After that your original formula should work correctly.
Addition:
It seems this is not a typical problem and it might have to do with the machine locale settings and date format recognition.
A possible workaround can be using this formula to retrieve the correct date value from a date text formatted as MMM d, yyyy:
=DATE(RIGHT(U9,4),
MATCH(LEFT(U9,3),
{"Jan","Feb","Mar","April","May","jun","Jul","Aug","Sep","Oct","Nov","Dec"}
,0),
NUMBERVALUE(MID(U9,5,2)))
For easy copy:
DATE(RIGHT(U9,4),MATCH(LEFT(U9,3),{"Jan","Feb","Mar","April","May","jun","Jul","Aug","Sep","Oct","Nov","Dec"},0),NUMBERVALUE(MID(U9,5,2)))
Replace the U9 part of your original formula with this formula.
I have been using the following as a formula array beginning in column R2 for an Excel spreadsheet that combines the data from four columns:
=L2&" "&N2&" "&Q2&" "&P2
Column L contains the date in the following format: 2/23/2015.
The formula used to show the date as shown above, but now for some reason the format has changed to go from 2/23/2015 to 42081.
I can't seem to get date to show as it once did. Also the Excel spreadsheet I apply this to is downloaded from a different source each day so I don't know if default formatting has changed even though the data is exactly the same.
When you concatenate like that you just get the values not the formatting because number formatting doesn't apply in the text string created. You can use TEXT function to dictate the format in this context, e.g.
=TEXT(L2,"m/d/yyyy")&" "&N2&" "&Q2&" "&P2
With MDY convention, if L2 is formatted as Text prior to entry then keying in 2/23/2015 would preserve that display in a formula that concatenates it with other strings. Similarly if not keyed but entered with Ctrl+:.
If L2 is formatted as General or Short Date the date index will be concatenated (42081 in the example above) though the display in L2 will not change.
While a change in formatting may be the most likely explanation (and a solution provided by #barry) another possibility is a change in the date convention from DMY. In which case 2/23/2015 would have displayed and concatenated as that even in a cell formatted as Short Date. 2/12/2015 in that case however would have displayed as such but in the 1900 date system concatenated as 42340 - the date serial number for December 2, not February 12.
I have following numbers, which actually represent dates in the YYYYMM format:
201301
201302
201303
...
When I try to format the cells to date fields, Excel always overwrites the original dates and creates some crazy dates, that have nothing in common with the actual ones.
How can I bring Excel to convert it properly?
Excel (by default) uses the 1900 date system. This simply means that the date 1 Jan 1900 has a true numeric value of 1, 2 Jan 1900 has a value of 2 etc. These values are called "serial values" in Excel and it is these serial values that allows us to use dates in calculations. which was discussed here.
So that explains why your data reflects a different date when you try to format is as Date.
What you need to do then is to transform it into a complete readable date format Excel recognize.
As is, Excel will use its default Serial Value conversion.
If you have your data in starting in A1, enter this in B1.
=DATEVALUE(SUBSTITUTE(A1,LEFT(A1,4),LEFT(A1,4)&"-")&"-01")
Above formula will then create a valid Date that Excel can interpret and read correctly.
Result will be:
41275
41306
41334
When you format it as Date, it will equate to the 1st day of every month.
1/1/2013
2/1/2013
3/1/2013
You can just fix the formatting using Custom Format to get YYYYMM as seen below:
If your range is small enough (in the example all 2013) then no formula is required. Replace 13 with 13-, apply Text to Columns with Tab as the delimiter and at Step 3 choose Date and YMD.
You can use the DATE and LEFT/RIGHT functions.
Assuming that format is consistent (i.e. 4 characters for year, 2 characters for month), to convert cell A1:
=DATE(LEFT(A1,4), RIGHT(A1,2), 1)
This will assume the first day of the month for the date (I assume that's irrelevant for you). You can then format the cell as you want.
Can you use formula in Excel to solve this..
A sample formula is given below
=DATE(MID(CELLID,1,4),MID(CELLID,5,2), 1)