Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Conversion CCYYMMDD to MMDDYY 1

Status
Not open for further replies.

mdabney

IS-IT--Management
Jul 1, 2002
77
US
I use the AS400 query function to dump information into Excel for massaging. Since the dreaded Y2K, our ERP solution added the century in front of the date. As in, today's date would copy as 1050214. I send these reports to other people who are having trouble with the dates. Is there an Excel formula that I could use to convert the dates?
 
Hi,

Today's date is
[tt]
01050214
[/tt]
where 01 is the CENTURY?

Would you represent the twentieth century as 00?

Assuming that then if your "date" is in A1...
[tt]
=DATE((IF(ISERROR(LEFT(A1,LEN(A1)-6)),0,LEFT(A1,LEN(A1)-6))*100+1900+IF(ISERROR(MID(A1,LEN(A1)-5,2)),MID(A1,LEN(A1)-4,1),MID(A1,LEN(A1)-5,2))),LEFT(RIGHT(A1,4),2),RIGHT(A1,2))
[/tt]


Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
Hi mdabney,

Assuming the dates are all numeric, I think this should work for you:

[blue][tt] =DATE(1900+FLOOR(MOD(A1,10^7),10^4)/10^4,FLOOR(MOD(A1,10^4),100)/100,MOD(A1,100))[/tt][/blue]


Skip,

I have seen that notation before and it's quite believable from an AS400.

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
=DATE(MID(A1,LEN(A1)-5,2)+2000,MID(A1,LEN(A1)-3,2),RIGHT(A1,2))

should work for dates 2000 and after...

[Blue]Blue[/Blue] [Dragon]

If I wasn't Blue, I would just be a Dragon...
 


Tony,

I like it! ==>*

Skip,

[glasses] [red]Be advised:[/red] The dyslexic, agnostic, insomniac, lays awake all night wondering...
"Is there really a DOG?" [tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top