Access - change date from 1968-05-04 00:00:00 UTC to short date

Please offer suggestions on how to change this date format:

1968-05-04 00:00:00 UTC

into a short date format in Access?

Thank you.
exp vgAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MacroShadowCommented:
Try this:
Format(Left("1968-05-04 00:00:00 UTC", 10),"short date")

Open in new window

exp vgAuthor Commented:
This helps - but is there a way to change this format into short date, not just this particular date.

Meaning, the date column will have dates other than 5/4/1968.

Thank you.
MacroShadowCommented:
Sure.

Change YourTable to the name of your table and SqlDate to the name of the field containing the date to be converted.

Sub Demo()

    Dim rs As DAO.Recordset
    Set rs = CurrentDb.OpenRecordset("SELECT * FROM YourTable")

    'Check if the recordset contains records
    If Not (rs.EOF And rs.BOF) Then
        rs.MoveFirst
        Do Until rs.EOF = True
        
            'Perform an edit
            rs.Edit
            On Error Resume Next
            rs!SqlDate = Format(Left(rs!SqlDate, 10), "short date")
            'Save the change
            rs.Update

            'Move to the next record. Don't forget to do this.
            rs.MoveNext
        Loop
    Else
        MsgBox "There are no records in the recordset."
    End If

    MsgBox "Finished converting dates."

    rs.Close
    Set rs = Nothing

End Sub

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
The 7 Worst Nightmares of a Sysadmin

Fear not! To defend your business’ IT systems we’re going to shine a light on the seven most sinister terrors that haunt sysadmins. That way you can be sure there’s nothing in your stack waiting to go bump in the night.

exp vgAuthor Commented:
Thank you for taking the time in offering this.

Is this possible in a simple query at all?
MacroShadowCommented:
Do you mean an update query?
exp vgAuthor Commented:
Thank you.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.