MS Access - 转换短文本的日期格式

MS Access - Converting Date Format for Short Text

我有一个带有 table Door Activity Log 的 .mdb Access 数据库。其中,有一个名为 Door Activity Log Date 的列,类型为 Short Text。目前,其格式为美国日期格式 (mm/dd/yyyy)。

如何在 Access 中 convert/manipulate 日期(我猜短文本只是字符串),使其变为 dd/mm/yyyy

我用 VBA

解决了
Private Sub dateFormattingConvert()

Dim rs As DAO.Recordset
Dim oldDate As String
Dim newDate As String
Dim year As String
Dim month As String
Dim day As String
Dim fullString As String
Set rs = CurrentDb.OpenRecordset("Door Activity Log")

If Not (rs.EOF And rs.BOF) Then
    rs.MoveFirst
    Do Until rs.EOF = True
        Debug.Print (rs![Door Activity Log Date])
        oldDate = rs![Door Activity Log Date]
        year = Right(oldDate, 4)
        month = Left(oldDate, 2)
        day = Mid(oldDate, 4, 2)
        fullString = day & "/" & month & "/" & year

        rs.Edit
        rs![Door Activity Log Date] = fullString
        rs.Update

        rs.MoveNext
    Loop
Else
    MsgBox "No more records."
End If

MsgBox "Finished"

rs.Close
Set rs = Nothing

End Sub

日期应始终存储为 日期,而不是文本。

因此,在 table、ActivityLogDate 中创建一个新字段,并用如下查询填充它:

Update 
    [Door Activity Log]
Set 
    ActivityLogDate = DateSerial(Mid([Activity Log Date], 7, 4), Mid([Activity Log Date], 1, 2), Mid([Activity Log Date], 4, 2))