我正在尝试将数据从PGSQl导入Excel,我只想在eventdate中导入那些年龄<18y(dob)的数据。 出生日期(dob)和eventdate进口均为dd / mm / yyyy 00:00
我应该如何将其写入我的SQL代码?
Sheets("Sheet1").Select
Range("A1").Select
Dim conn As New Connection
conn.ConnectionString = sqlconnection
conn.Open
Dim rs As Recordset
Dim ITEM As String
ITEM = "SELECT user.id,surname,forename,dob,source.eventdate,source.item " _
& "FROM source INNER JOIN user ON source.id=user.id " _
& "WHERE ???? "
Set rs = conn.Execute(ITEM)
With ActiveSheet.QueryTables.Add(Connection:=rs, Destination:=Range("A1"))
.Refresh
End With
rs.Close