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, 7 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
-
Mozilla Firefox Security Updates! Released late 17th May 2025
by
Alex5723
5 hours, 36 minutes ago -
Microsoft: Troubleshoot problems updating Windows
by
Alex5723
2 hours, 29 minutes ago -
Woman Files for Divorce After ChatGPT “Reads” Husband’s Coffee Cup
by
Alex5723
9 hours, 35 minutes ago -
Moving fwd, Win 11 Pro,, which is best? Lenovo refurb
by
Deo
3 hours, 1 minute ago -
DBOS Advanced Network Analysis
by
Kathy Stevens
19 hours, 24 minutes ago -
Microsoft Edge Launching Automatically?
by
healeyinpa
9 hours, 49 minutes ago -
Google Chrome to block admin-level browser launches for better security
by
Alex5723
22 hours, 5 minutes ago -
iPhone SE2 Stolen Device Protection
by
Rick Corbett
14 hours, 20 minutes ago -
Some advice for managing my wireless internet gateway
by
LHiggins
10 hours, 1 minute ago -
NO POWER IN KEYBOARD OR MOUSE
by
HE48AEEXX77WEN4Edbtm
16 hours, 17 minutes ago -
A CVE-MITRE-CISA-CNA Extravaganza
by
Nibbled To Death By Ducks
1 day, 7 hours ago -
Sometimes I wonder about these bots
by
Susan Bradley
1 day, 3 hours ago -
Does windows update component store “self heal”?
by
Mike Cross
17 hours, 54 minutes ago -
Windows 11 Insider Preview build 27858 released to Canary
by
joep517
1 day, 21 hours ago -
Pwn2Own Berlin 2025: Day One Results
by
Alex5723
5 hours, 28 minutes ago -
Windows 10 might repeatedly display the BitLocker recovery screen at startup
by
Susan Bradley
9 hours, 9 minutes ago -
Windows 11 Insider Preview Build 22631.5409 (23H2) released to Release Preview
by
joep517
2 days ago -
Windows 10 Build 19045.5912 (22H2) to Release Preview Channel
by
joep517
2 days ago -
Kevin Beaumont on Microsoft Recall
by
Susan Bradley
1 day, 12 hours ago -
The Surface Laptop Studio 2 is no longer being manufactured
by
Alex5723
2 days, 8 hours ago -
0Patch, where to begin
by
cassel23
2 days, 2 hours ago -
CFPB Quietly Kills Rule to Shield Americans From Data Brokers
by
Alex5723
2 days, 22 hours ago -
89 million Steam account details just got leaked,
by
Alex5723
2 days, 9 hours ago -
KB5058405: Linux – Windows dual boot SBAT bug, resolved with May 2025 update
by
Alex5723
3 days, 6 hours ago -
A Validation (were one needed) of Prudent Patching
by
Nibbled To Death By Ducks
2 days, 21 hours ago -
Master Patch Listing for May 13, 2025
by
Susan Bradley
2 days, 8 hours ago -
Installer program can’t read my registry
by
Peobody
6 minutes ago -
How to keep Outlook (new) in off position for Windows 11
by
EspressoWillie
2 days, 19 hours ago -
Intel : CVE-2024-45332, CVE-2024-43420, CVE-2025-20623
by
Alex5723
3 days, 2 hours ago -
False error message from eMClient
by
WSSebastian42
3 days, 17 hours 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.