[英]how to add datetime value from excel cell using VBA into SQL table
Can anyone help? 有人可以帮忙吗?
strSql = "INSERT INTO EmailRT (rs.Fields(0).Value, rs.Fields(1).Value) " & _
" VALUES (" & _
"'" & shtSheetToWork.Cells(2, 1).Value & "', " & _
"'" & shtSheetToWork.Cells(2, 2).Value & "')"
In cell (2,2), the value is 21/10/2014 22:32 how do i add this to Sql table into column rs.Fields(1).Value whose data type is datetime 在单元格(2,2)中,值为21/10/2014 22:32如何将其添加到Sql表中的rs.Fields(1)列中,其数据类型为datetime
1) You can format the cell as you need (in Ctrl+1 ). 1)您可以根据需要设置单元格的格式(在Ctrl + 1中 )。 And then use shtSheetToWork.Cells(2, 1).Text
然后使用shtSheetToWork.Cells(2, 1).Text
2) You can use VBA Format. 2)您可以使用VBA格式。 Format(shtSheetToWork.Cells(2, 1).Text, "yyyyMMdd")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.