For a client, I created a db having one table, which contains over 1.3M records and 32 fields. There are three date fields. In my haste to import the source text file, I set up only one of the three date fields as dates — the other two came in as long integers.
With long integers, of course, a date intended to be “5/12/06” becomes “51206”, not “051206”. Thus, “dates” in months 10-12 contain six digits, but the other “dates” contain five digits.
Is there either a VBA or a non-VBA solution to convert all those 1.3M x 2 = 2.6M long integers in those two fields to dates?
I failed pretty badly trying to come up with an update query to do this. By the way, I would be happy to do just one of the two date fields at a time, if that simplifies the process!
Thanks very much.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Date convert – string to m/dd/yy (Access 2003)
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Date convert – string to m/dd/yy (Access 2003)
- This topic has 9 replies, 3 voices, and was last updated 16 years, 8 months ago.
AuthorTopicJohnS1606
AskWoody LoungerOctober 1, 2008 at 9:24 am #454355Viewing 1 reply threadAuthorReplies-
WSHansV
AskWoody LoungerOctober 1, 2008 at 9:38 am #1127657Let’s say that the two number fields are named Long1 and Long2
Create two new date/time fields in the table, let’s say Date1 and Date2.Create a query based on the table.
Add Long1 and Date1 to the query grid.
Select Query | Update Query.
Set the Criteria for Long1 to Is Not Null.
Set the Update to for Date1 toDateSerial(1900 – 100 * (([Long1] Mod 100) < 30) + ([Long1] Mod 100), [Long1] 10000, ([Long1] 100) Mod 100)
Run the query.
Do the same for Long2 and Date2. -
JohnS1606
AskWoody Lounger -
WSHansV
AskWoody LoungerOctober 2, 2008 at 2:02 am #1127751The operator performs integer division: for example 13 5 returns 2, because 5 goes 2 times into 13. The remainder of 3 is discarded.
With a number representing a date such as 51208: 51208 100 returns 512, and 512 Mod 100 is the remainder of 512 after division by 100, i.e. the day number 12.
-
-
JohnS1606
AskWoody LoungerOctober 2, 2008 at 4:18 am #1127790Hans: Please ignore my post #735,972 — I found the necessary reference to usage of the backslash as a truncate function. Also, I have for the first time discovered that the DateSerial function will accept parameters which are not only integers, but real numbers. I tried something like DateSerial(2008.123,4,12), and it dutifully resolved it like DateSerial(2008,4,12)!
Is it possible that the sign after “DateSerial(1900…” in your formula should be plus, not minus? Somehow, the formula seems to resolve to the correct answer with the minus sign, but I don’t understand why.
jes -
WSHansV
AskWoody LoungerOctober 2, 2008 at 4:29 am #1127792If the year yy is less than 30, for example 08, we assume that it is in this century, i.e. 08 stands for 2008.
If the year yy is 30 or more, for example 95, we assume that it belongs to last century, i.e. 95 stands for 1995.
So we want to add 2000 or 1900 to yy depending on whether it is less than 30 or not.
We do this by adding 1900 in all situations, and then adding another 100 if necessary.The result of (([Long1] Mod 100) < 30) is either True or False, depending on whether the remainder of Long1 after division by 100 is less than 30 or not.
In VBA and hence in Access, True equals -1 and False equals 0. Multiplying this by 100 we get -100 or 0. To add 100, we subtract -100. Hence the – instead of +. -
JohnS1606
AskWoody Lounger
-
-
-
-
WSJezza
AskWoody LoungerOctober 1, 2008 at 10:06 am #1127661(Edited by Jezza on 01-Oct-08 23:06. To change the code to take into consideration different string lengths)
In addition you could use the following UDF to convert the date by adding it to a module
Function DateChange(datFormat As String) As Date
Dim datMonth As String
Dim datDay As String
Dim datYear As StringIf Len(datFormat) < 6 Then
datMonth = Left(datFormat, 1)
datDay = Mid(datFormat, 2, 2)
datYear = Right(datFormat, 2)Else
datMonth = Left(datFormat, 2)
datDay = Mid(datFormat, 3, 2)
datYear = Right(datFormat, 2)
End IfDateChange = datMonth & "/" & datDay & "/" & datYear
You can then create a query using the function in the format of NewDate: DateChange([StartDate])
HTH
Viewing 1 reply thread -

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
-
Music : The Rose Room – It’s Been A Long, Long Time album
by
Alex5723
33 minutes ago -
Disengage Bitlocker
by
CWBillow
1 hour, 57 minutes ago -
Mac Mini M2 Service Program for No Power Issue
by
Alex5723
2 hours, 32 minutes ago -
New Win 11 Pro Geekom Setup questions
by
Deo
4 hours, 17 minutes ago -
Windows 11 Insider Preview build 26200.5651 released to DEV
by
joep517
9 hours, 48 minutes ago -
Windows 11 Insider Preview build 26120.4441 (24H2) released to BETA
by
joep517
9 hours, 49 minutes ago -
iOS 26,, MacOS 26 : Create your own AI chatbot
by
Alex5723
13 hours, 44 minutes ago -
New PC transfer program recommendations?
by
DaveBoston
4 hours, 5 minutes ago -
Windows 11 Insider Preview Build 22631.5545 (23H2) released to Release Preview
by
joep517
17 hours, 49 minutes ago -
Windows 10 Build 19045.6029 (22H2) to Release Preview Channel
by
joep517
17 hours, 50 minutes ago -
Best tools for upgrading a Windows 10 to an 11
by
Susan Bradley
6 hours, 9 minutes ago -
The end of Windows 10 is approaching, consider Linux and LibreOffice
by
Alex5723
3 hours, 31 minutes ago -
Extended Windows Built-in Disk Cleanup Utility
by
bbearren
15 hours, 59 minutes ago -
Win 11 24H2 June 2025 Update breaks WIFI
by
dportenlanger
1 day, 12 hours ago -
Update from WinPro 10 v. 1511 on T460p?
by
CatoRenasci
10 hours, 43 minutes ago -
System Restore and Updates Paused
by
veteran
1 day, 15 hours ago -
Windows 10/11 clock app
by
Kathy Stevens
1 day, 2 hours ago -
Turn off right-click draw
by
Charles Billow
1 day, 18 hours ago -
Introducing ChromeOS M137 to The Stable Channel
by
Alex5723
1 day, 22 hours ago -
Brian Wilson (The Beach Boys) R.I.P
by
Alex5723
15 hours, 58 minutes ago -
Master patch listing for June 10, 2025
by
Susan Bradley
1 day, 23 hours ago -
Suggestions for New All in One Printer and a Photo Printer Windows 10
by
Win7and10
1 day, 2 hours ago -
Purchasing New Printer. Uninstall old Printer Software First?
by
Win7and10
2 days, 5 hours ago -
KB5060842 Issue (Minor)
by
AC641
17 hours, 48 minutes ago -
EchoLeak : Zero Click M365 Copilot leak sensitive information
by
Alex5723
2 days, 12 hours ago -
24H2 may not be offered June updates
by
Susan Bradley
1 day, 5 hours ago -
Acronis : Tracking Chaos RAT’s evolution (Windows, Linux)
by
Alex5723
3 days, 1 hour ago -
June 2025 updates are out
by
Susan Bradley
6 hours, 49 minutes ago -
Mozilla shutting Deep Fake Detector
by
Alex5723
3 days, 16 hours ago -
Windows-Maintenance-Tool (.bat)
by
Alex5723
3 days, 1 hour ago
Recent blog posts
Key Links
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.