Solved

Formatting Dates Again!

Posted on 2007-03-26
1
191 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
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now