excel vba - VBA Date shown as Number -


i new vba , need rows out of database. problem date first time selected shown in format dd.mm.yyyy, after time date shown whole number 42814 or that.

here 2 pictures better understanding

image1 image2

and here code

application.cutcopymode = false     activesheet.listobjects.add(sourcetype:=0, source:= _         "odbc;dsn=opsapps;uid=alligatoah;trusted_connection=yes;app=microsoft office 2016;wsid=at000616;database=opsapps" _         , destination:=range("$a$1")).querytable         .commandtext = array( _         "select tv.customer, tv.knum, tv.dmrf, tv.bom, tv.costs, tv.plnlaunch, tv.date, tv" _         , _         "_.actualcosts" & chr(13) & "" & chr(10) & "from opsapps.dbo.tv tv" & chr(13) & "" & chr(10) & "where (tv.systemmcsdate>={ts '2017-01-01 00:00:00'})" _         )         .rownumbers = false         .filladjacentformulas = false         .preserveformatting = true         .refreshonfileopen = false         .backgroundquery = true         .refreshstyle = xlinsertdeletecells         .savepassword = false         .savedata = true         .adjustcolumnwidth = true         .refreshperiod = 0         .preservecolumninfo = true         .listobject.displayname = "table_query_from_villachopsapps"         .refresh backgroundquery:=false     end 

can help? in advance.

you want set numberformat property of range

for example, if have 18/08/17 in cell , convert numberformat manually in excel ribbon "general", see 42965. can specify format in vba using string so:

' use column here, use table range thisworkbook.sheets("mysheet").columns("f").numberformat = "dd.mm.yyyy" 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -