0

I got errors converting an Excel date to SQL Server.

Conversion failed when converting date and/or time from character string

rs.open "Table", con, adOpenDynamic, adLockOptimistic, adCmdTable
rs.addNew
rs("DateColumn") = rng.Value

I solved the problem adapting this answer

Pᴇʜ
  • 53,845
  • 9
  • 46
  • 68
GUI Junkie
  • 529
  • 1
  • 17
  • 29

1 Answers1

0

I solved this using this code:

If rng.NumberFormat = "m/d/yyyy" Then
    rs("DateColumn") = CLng(Format(rng.Value, "yyyymmdd"))
End If
GUI Junkie
  • 529
  • 1
  • 17
  • 29