Solved: Access date format change

Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

[email protected]

Thread Starter
Joined
Jul 1, 2008
Messages
24
Hi. Imported table has dd:mm:yy dates in two fields, illegible to Access. So I'm trying to change these to dd/mm/yy.
I'm getting syntax error (missing operator) in the strings. Any ideas?

Dim Dobdate As String
Dim Labdate As String
Dobdate = "UPDATE [New Non Trait Data] SET [Dob] = [0-9][0-9]/[0-9][0-9]/[0-9][0-9] WHERE [Dob] = [0-9][0-9]:[0-9][0-9]:[0-9][0-9] "
Labdate = "UPDATE [New Non Trait Data] SET [Lab date] = [0-9][0-9]/[0-9][0-9]/[0-9][0-9] WHERE [Lab date] = [0-9][0-9]:[0-9][0-9]:[0-9][0-9] "
DoCmd.RunSQL (Dobdate)
DoCmd.RunSQL (Labdate)
 

OBP

Joined
Mar 8, 2005
Messages
19,895
You do need VBA to do this, you can use either an Update query where you split up the incorrectly formatted date and put it back together with the correct "/" in place or you can just use a simple replace Query to replace the ":" with "/".
 

[email protected]

Thread Starter
Joined
Jul 1, 2008
Messages
24
Thanks Tony. Sorted. Cheers.
Private Sub Private_Sub_Copy_to_PD_Click___Click()
Dim NTDob As String
Dim NTLabDate As String
NTDob = "UPDATE [New Non Trait Data] SET [New Non Trait Data].[Dob] = Replace([Dob],':','/');"
NTLabDate = "UPDATE [New Non Trait Data] SET [New Non Trait Data].[Lab date] = Replace([Lab date],':','/');"
DoCmd.RunSQL (NTDob)
DoCmd.RunSQL (NTLabDate)
 
Status
This thread has been Locked and is not open to further replies. Please start a New Thread if you're having a similar issue. View our Welcome Guide to learn how to use this site.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 807,865 other people just like you!

Latest posts

Staff online

Members online

Top