Have recently upgraded to Office 2k from 97, and possibly wish I hadn’t.
I have an application which exports as a csv a load of data about people, dates, and money.
To analyse it and do useful things with it, I import it monthly into an ambitious (my style) workbook, replacing the previous month’s data.
This is done with a ‘point and shoot’ macro, slightly tidied and the usual screenupdating = false trick applied.
It seems a ‘feature’ of Excel 2000 that much of the dates part of the data is corrupted in this process (didn’t happen with ’97!) Days and months get inverted.
I’ve tried emptying the columns in the target workbook and formatting them as dd/mm/yy ‘in advance’ but that doesn’t stop bad things happening.
Crazily enough, if the dates in the csv are copied and pasted ‘by hand’ into the target, there’s no problem. But I’d rather fix it (with help from here.)
The attached file shows the unwanted behaviour.
The macro code (don’t laugh!) is in the text file.
The danger of this, for which I won’t thank Mr Gates, is that I could get sent to prison for alleging that someone’s reneging on a loan, when they’re not!
![]() |
There are isolated problems with current patches, but they are well-known and documented on this site. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
dates corrupted on import (2000 SP3)
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » dates corrupted on import (2000 SP3)
- This topic has 25 replies, 4 voices, and was last updated 21 years, 1 month ago.
AuthorTopicWSitshimathome
AskWoody LoungerApril 18, 2004 at 9:46 pm #403817Viewing 3 reply threadsAuthorReplies-
WSitshimathome
AskWoody Lounger -
WSJohnBF
AskWoody LoungerApril 18, 2004 at 9:59 pm #816636John, I suspect the translation failure is because the import is assuming the US mm/dd/yy system, when the incoming data is dd/mm/yy. Hence dates which would be invalid in the US, with any day higher than 12, are treated as text, and in the conversions of ‘apparently’ valid dates, the month and day are transposed.. What do you have set as the OS default short date under Control Panel, Regional settings?
-
WSitshimathome
AskWoody Lounger -
WSJohnBF
AskWoody LoungerApril 18, 2004 at 10:53 pm #816653John, according to post 206918 and post 196619, 2000 doesn’t play well with non-US dates. You may have to tweak your code.
-
WSJohnBF
AskWoody LoungerApril 18, 2004 at 10:53 pm #816654John, according to post 206918 and post 196619, 2000 doesn’t play well with non-US dates. You may have to tweak your code.
-
WSJohnBF
AskWoody LoungerApril 19, 2004 at 3:54 am #816685John, try this code to convert your dates; test it carefully. You will have to modify it to fit your actual workbook and worksheet names, etc.
Sub mmddyy2ddmmyydates()
Dim rngDates As Range, rngCell As Range
Dim varDate As Variant
Set rngDates = Intersect(ActiveSheet.UsedRange, Columns(“I:J”))
If Not rngDates Is Nothing Then
For Each rngCell In rngDates
If InStr(rngCell.Value, “/”) Then
varDate = Split(rngCell.Value, “/”, , vbTextCompare)
rngCell.Value2 = DateSerial(varDate(2), varDate(1), varDate(0))
End If
Next rngCell
rngDates.NumberFormat = “dd/mm/yy”
End If
End Sub -
WSJohnBF
AskWoody LoungerApril 19, 2004 at 3:54 am #816686John, try this code to convert your dates; test it carefully. You will have to modify it to fit your actual workbook and worksheet names, etc.
Sub mmddyy2ddmmyydates()
Dim rngDates As Range, rngCell As Range
Dim varDate As Variant
Set rngDates = Intersect(ActiveSheet.UsedRange, Columns(“I:J”))
If Not rngDates Is Nothing Then
For Each rngCell In rngDates
If InStr(rngCell.Value, “/”) Then
varDate = Split(rngCell.Value, “/”, , vbTextCompare)
rngCell.Value2 = DateSerial(varDate(2), varDate(1), varDate(0))
End If
Next rngCell
rngDates.NumberFormat = “dd/mm/yy”
End If
End Sub
-
-
WSitshimathome
AskWoody Lounger
-
-
WSJohnBF
AskWoody LoungerApril 18, 2004 at 9:59 pm #816637John, I suspect the translation failure is because the import is assuming the US mm/dd/yy system, when the incoming data is dd/mm/yy. Hence dates which would be invalid in the US, with any day higher than 12, are treated as text, and in the conversions of ‘apparently’ valid dates, the month and day are transposed.. What do you have set as the OS default short date under Control Panel, Regional settings?
-
-
WSitshimathome
AskWoody Lounger -
WSAndrewO
AskWoody LoungerApril 19, 2004 at 6:21 am #816720John
Another take on the same thing. (As a New Zealander I have the same issues you do plus some (Dictionaries))
If I have control of writing the file – its easy. Write the dates with a format that includes alphas e.g. 01Jan04 or any sensible variants.
Excel then cannot screw up as the dates are
a) recognised, and
unambiguous.
Another trick that works is to use Word to pre-alter the text as above before import (Replace all “/01/” with “Jan” …)
HTH
-
WSitshimathome
AskWoody LoungerApril 19, 2004 at 6:43 am #816726John, Andrew,
Thanks very much for your trouble, knowledge and imagination. I’ll try John’s solution first, as that was the first to show (and will also be a better ‘learning experience’: I think I can figure (pun) what it’s doing, the ‘datevalue’ is the giveaway.)
For a really clunky solution, I was thinking about using LEFT, RIGHT and MID formulas to split the dates into three elements (3 new columns for each column of dates), letting neo-colonialist Excel do its stuff on the import, then when safely there, concatenate the d, m and y bits and seeing if that was recognised as a date.
I have got control of the file, so there’s no problem about Andrew’s method if I go that way.
In the meantime, life’s too short, so I’ll go for a prebuilt solution.
Thanks again. -
WSAndrewO
AskWoody LoungerApril 19, 2004 at 8:28 am #816736John
One more thought – although this is untested. My experience with VBA CSV imports suggests that the following occurs for each datea) if the date can be interpreted as US it will be – e.g. 01/03/2004 will be stored in Excel’s internal date form as 3rd Jan 2004
if it cannot be interpreted as US it is left as text e.g. 25/03/2004
Your problem is therefore twofold
a) decode the string ones (easy-peasy) , converting to a date format
recode the date ones to their correct month
I think John’s code achieves the first, but not the second – I’d expect an Else on the IF statement.
-
WSpieterse
AskWoody LoungerApril 19, 2004 at 10:27 am #816763Hi Guys,
The very best way around this problem is to NOT do a csv import.
The steps I’d suggest:
– temporary rename the file to another extension (txt)
– switch on the macro recorder
– open the txt file in Excel and choose the proper format.
– on the final step, make sure to select the column with the dates and choose the proper date format
– stop recording the macro, and check out the WOrkbooks.OpenText method. Adapt it to accept the normal csv filename.Of course this is not tested, so maybe it still fails, since VBA speaks American…
-
WSitshimathome
AskWoody LoungerApril 19, 2004 at 9:50 pm #817085Thanks for all the great ideas, chaps. As there’s no great rush on this (it’s no big deal to do the copy + paste by hand once a month) I’m going to have some fun with it (and maybe learn a bit.)
Am trying turning the dates which are dates (ie not text) into serial number dates and defying xl, or vba, to ‘Americanise’ them, before applying a date format the way round I want.
I figure that what we need is a ‘Copy Special’ a la WYSIWYG just as we have 10 kinds of Paste Special *grin*.
Am curious about the New Zealand dictionaries: have the real ones got all the words upside down? -
WSpieterse
AskWoody LoungerApril 20, 2004 at 5:29 am #817195Since this is a once-a-month thing, consider using Data, Get External data, new Text query to import your data into a sheet directly.
Next month, you select the sheet with the data and hit refresh data. You’ll be prompted for a filename.
You might have to rename the file to txt first though.
-
WSitshimathome
AskWoody LoungerApril 20, 2004 at 6:37 pm #817515Yes, Jan Karel, thought of this too.
A potential difficulty is that the monthly csv goes to sundry other people too, to refresh the big application which they need to interrogate, too.
That’s why the macro is set up to read from a floppy disc: that’s how it goes to two of the users, the others get it by email and they all know how to detach an email attachment to a floppy.
I’m not too confident about their being able to detach it confidently to a specified folder with a specified path on their hard drives.
Doesn’t the ‘get external data’ route depend on access to the external data every time the analysis file is opened?
I’m going to play with this in a number of ways over the next few days. Meanwhile, a domestic crisis intervenes….
The odd thing is, I don’t ever recall having this difficulty when the analysis tool was in xl 97. So apparently xl VBA comes in flavours? -
WSpieterse
AskWoody Lounger -
WSpieterse
AskWoody Lounger -
WSitshimathome
AskWoody LoungerApril 20, 2004 at 6:37 pm #817516Yes, Jan Karel, thought of this too.
A potential difficulty is that the monthly csv goes to sundry other people too, to refresh the big application which they need to interrogate, too.
That’s why the macro is set up to read from a floppy disc: that’s how it goes to two of the users, the others get it by email and they all know how to detach an email attachment to a floppy.
I’m not too confident about their being able to detach it confidently to a specified folder with a specified path on their hard drives.
Doesn’t the ‘get external data’ route depend on access to the external data every time the analysis file is opened?
I’m going to play with this in a number of ways over the next few days. Meanwhile, a domestic crisis intervenes….
The odd thing is, I don’t ever recall having this difficulty when the analysis tool was in xl 97. So apparently xl VBA comes in flavours? -
WSpieterse
AskWoody LoungerApril 20, 2004 at 5:29 am #817196Since this is a once-a-month thing, consider using Data, Get External data, new Text query to import your data into a sheet directly.
Next month, you select the sheet with the data and hit refresh data. You’ll be prompted for a filename.
You might have to rename the file to txt first though.
-
WSitshimathome
AskWoody LoungerApril 19, 2004 at 9:50 pm #817086Thanks for all the great ideas, chaps. As there’s no great rush on this (it’s no big deal to do the copy + paste by hand once a month) I’m going to have some fun with it (and maybe learn a bit.)
Am trying turning the dates which are dates (ie not text) into serial number dates and defying xl, or vba, to ‘Americanise’ them, before applying a date format the way round I want.
I figure that what we need is a ‘Copy Special’ a la WYSIWYG just as we have 10 kinds of Paste Special *grin*.
Am curious about the New Zealand dictionaries: have the real ones got all the words upside down?
-
-
-
WSAndrewO
AskWoody LoungerApril 19, 2004 at 8:28 am #816737John
One more thought – although this is untested. My experience with VBA CSV imports suggests that the following occurs for each datea) if the date can be interpreted as US it will be – e.g. 01/03/2004 will be stored in Excel’s internal date form as 3rd Jan 2004
if it cannot be interpreted as US it is left as text e.g. 25/03/2004
Your problem is therefore twofold
a) decode the string ones (easy-peasy) , converting to a date format
recode the date ones to their correct month
I think John’s code achieves the first, but not the second – I’d expect an Else on the IF statement.
-
-
WSitshimathome
AskWoody LoungerApril 19, 2004 at 6:43 am #816727John, Andrew,
Thanks very much for your trouble, knowledge and imagination. I’ll try John’s solution first, as that was the first to show (and will also be a better ‘learning experience’: I think I can figure (pun) what it’s doing, the ‘datevalue’ is the giveaway.)
For a really clunky solution, I was thinking about using LEFT, RIGHT and MID formulas to split the dates into three elements (3 new columns for each column of dates), letting neo-colonialist Excel do its stuff on the import, then when safely there, concatenate the d, m and y bits and seeing if that was recognised as a date.
I have got control of the file, so there’s no problem about Andrew’s method if I go that way.
In the meantime, life’s too short, so I’ll go for a prebuilt solution.
Thanks again.
-
-
WSAndrewO
AskWoody LoungerApril 19, 2004 at 6:21 am #816721John
Another take on the same thing. (As a New Zealander I have the same issues you do plus some (Dictionaries))
If I have control of writing the file – its easy. Write the dates with a format that includes alphas e.g. 01Jan04 or any sensible variants.
Excel then cannot screw up as the dates are
a) recognised, and
unambiguous.
Another trick that works is to use Word to pre-alter the text as above before import (Replace all “/01/” with “Jan” …)
HTH
Viewing 3 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
.NET 8.0 Desktop Runtime (v8.0.16) – Windows x86 Installer
by
WSmeyerbos
6 hours, 12 minutes ago -
Neowin poll : What do you plan to do on Windows 10 EOS
by
Alex5723
1 hour, 55 minutes ago -
May 31, 2025—KB5062170 (OS Builds 22621.5415 and 22631.5415 Out-of-band
by
Alex5723
4 hours, 46 minutes ago -
Discover the Best AI Tools for Everything
by
Alex5723
4 hours, 54 minutes ago -
Edge Seems To Be Gaining Weight
by
bbearren
5 hours, 38 minutes ago -
Rufus is available from the MSFT Store
by
PL1
3 hours, 6 minutes ago -
Microsoft : Ending USB-C® Port Confusion
by
Alex5723
1 day, 5 hours ago -
KB5061768 update for Intel vPro processor
by
drmark
12 hours, 22 minutes ago -
Outlook 365 classic has exhausted all shared resources
by
drmark
8 hours, 33 minutes ago -
My Simple Word 2010 Macro Is Not Working
by
mbennett555
1 day, 1 hour ago -
Office gets current release
by
Susan Bradley
1 day, 4 hours ago -
FBI: Still Using One of These Old Routers? It’s Vulnerable to Hackers
by
Alex5723
2 days, 18 hours ago -
Windows AI Local Only no NPU required!
by
RetiredGeek
2 days, 2 hours ago -
Stop the OneDrive defaults
by
CWBillow
2 days, 19 hours ago -
Windows 11 Insider Preview build 27868 released to Canary
by
joep517
3 days, 5 hours ago -
X Suspends Encrypted DMs
by
Alex5723
3 days, 7 hours ago -
WSJ : My Robot and Me AI generated movie
by
Alex5723
3 days, 7 hours ago -
Botnet hacks 9,000+ ASUS routers to add persistent SSH backdoor
by
Alex5723
3 days, 8 hours ago -
OpenAI model sabotages shutdown code
by
Cybertooth
3 days, 8 hours ago -
Backup and access old e-mails after company e-mail address is terminated
by
M W Leijendekker
2 days, 21 hours ago -
Enabling Secureboot
by
ITguy
3 days, 4 hours ago -
Windows hosting exposes additional bugs
by
Susan Bradley
3 days, 16 hours ago -
No more rounded corners??
by
CWBillow
3 days, 12 hours ago -
Android 15 and IPV6
by
Win7and10
3 days, 2 hours ago -
KB5058405 might fail to install with recovery error 0xc0000098 in ACPI.sys
by
Susan Bradley
4 days, 5 hours ago -
T-Mobile’s T-Life App has a “Screen Recording Tool” Turned on
by
Alex5723
4 days, 7 hours ago -
Windows 11 Insider Preview Build 26100.4202 (24H2) released to Release Preview
by
joep517
4 days, 2 hours ago -
Windows Update orchestration platform to update all software
by
Alex5723
4 days, 15 hours ago -
May preview updates
by
Susan Bradley
4 days, 2 hours ago -
Microsoft releases KB5061977 Windows 11 24H2, Server 2025 emergency out of band
by
Alex5723
3 days, 18 hours ago
Recent blog posts
Key Links
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.