Solved

Formatting Dates Again!

Posted on 2007-03-26
1
196 Views
Last Modified: 2010-04-30
I have market data that I input into an array then copy to a worksheet.  For format of the text files is as follows:
10032005,3910,3910,3910,3910,10,3,2
1022007,3910,3910,3910,3910,10,3,2
The first column is the date in the format  mm/dd/yyyy,  But the month may be 1 or 2 chars i.e "1" not "01".

When I format my cell in excel to be a date in the form mm/dd/yyyy the input text 10032005 does not give me 10/03/2005 but 10/04/2020.  I need to use VBA to get the correct result.  But can anyone explain this?  
0
Comment
Question by:gamadmin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 1

Accepted Solution

by:
mattbroomhall earned 250 total points
ID: 18794660
This formula can read both formats, where A1 is replaced with the cell you have the date in.

=DATE(RIGHT(A1,4),IF(LEN(A1)=8,RIGHT(LEFT(A1,LEN(A1)-4),2),RIGHT(LEFT(A1,LEN(A1)-4),1)),LEFT(A1,2))
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question