将日期从SQL Server导入MS Access

时间:2014-03-03 03:10:14

标签: sql vba ms-access access-vba

我正在通过存储过程将SQL Server中的表导入MS Access。所有代码都运行正常,但我似乎无法从SQL Server正确导入日期。

这是我在VBA中的代码:

Dim db As Database
Dim myTable As TableDef
Dim myField As Field
Dim myProp As Property
Set db = CurrentDb

Set myTable = db.CreateTableDef("tblPaxGraphData")

With myTable
    .Fields.Append .CreateField("year_ending", dbDate)
    .Fields.Append .CreateField("pax", dbInteger)
    .Fields.Append .CreateField("transactions", dbInteger)
    .Fields.Append .CreateField("time_band", dbText)
    .Fields.Append .CreateField("day_type", dbText)
    .Fields.Append .CreateField("entrance", dbText)
    .Fields.Append .CreateField("ticketing_system", dbText)
End With

db.TableDefs.Append myTable
Set myField = myTable.Fields("year_ending")
Set myProp = myField.CreateProperty("Format", dbText, "Short Date")
myField.Properties.Append myProp
Application.RefreshDatabaseWindow

在SQL Server中,我有一个Date类型的列。

以下是我导入日期列后的样子(假设所有日期都是:

2013-03-31
2013-06-30
2013-09-30
2013-12-31
):

0 个答案:

没有答案