I am trying to populate my Access Table that has a date column from my excel, so in my excel I have DateOfBirth
formatted as dd/mm/yyyy
. In my Visual Basic Code this line print my date properly:
MsgBox "DOB: " & Format(xlWs.Cells(i, 9), "dd/mm/yyyy")
. My problem now is using this code:
sql = "INSERT INTO Persons(PersonName, Dob) VALUES('" & xlWs.Cells(i, 8) & "'," & Format(xlWs.Cells(i, 9), "dd/mm/yyyy") & ");"
DoCmd.SetWarnings False
DoCmd.RunSQL (sql)
DoCmd.SetWarnings True
where xlWs.Cells(i, 9)
is the date from my excel column and dob column in my table is of type Date/Time and Format as Short Date. My problem now is all my rows in dob column in Persons table becomes: 30/12/1899. How to fix this?