1

I'm trying to import data from PGSQl into Excel and I ONLY want to import those that are aged <18y (dob) as of the eventdate. Both the date of birth (dob) and eventdate imports as dd/mm/yyyy 00:00

How should I write this into my SQL code?

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
BradleyS
  • 201
  • 2
  • 11

0 Answers0