Hi all,
I have recently noticed that when I run a query from a macro, like...:
... I get cells wita a date value as numbers. When I use Microsoft Query directly, I get date values as dates. Why is that so? I would also like to gat gates from macro (and I know I can add this to the code - but what is the point in adding another text of code).
Cheers!
I have recently noticed that when I run a query from a macro, like...:
Code:
Sub My_Q()
With ActiveSheet.ListObjects.Add(SourceType:=0, Source:="ODBC;DRIVER=XXX Server;SERVER=XXX;", Destination:=Range("$A$1")).QueryTable
.CommandText = ("SELECT Table.ID" & Chr(13) & "" & Chr(10) & "FROM MyDB.dbo.Data Data")
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.PreserveColumnInfo = True
.ListObject.DisplayName = "Kwerenda_ListyPlac"
.Refresh BackgroundQuery:=False
End With
End Sub
... I get cells wita a date value as numbers. When I use Microsoft Query directly, I get date values as dates. Why is that so? I would also like to gat gates from macro (and I know I can add this to the code - but what is the point in adding another text of code).
Cheers!