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ᴇʜ
  • 56,719
  • 10
  • 49
  • 73
GUI Junkie
  • 539
  • 1
  • 17
  • 31

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
  • 539
  • 1
  • 17
  • 31