c# - DateTime does a wrong conversion -
i' downloading data sharepoint list containing column of type system.datetime
. think problem similar one: wrong conversion datetime in sql server . i'm working in c# , not ms excel..
for example, datetime in sharepoint 06.02.2017 08:24:12. now, i'm downloading using oledb , get: 06.02.2017 06:24:12. (utc-02:00)
i tried several conversions tolocaltime()
or touniversal()
, time changes it's getting worse.
does know, kind of conversion have use? i'm living in berlin, germany (utc+01:00).
thank much, jan
i'm downloading data system.data.datatable()
function, added it:
public void loadsharepointlist(string sql_string = "") { #region local variables string strsql = string.empty; system.data.oledb.oledbcommand cmd = null; system.data.dataset ds = null; system.data.oledb.oledbdataadapter da = null; #endregion #region getdatafromsharepoint system.data.oledb.oledbconnection conn = new system.data.oledb.oledbconnection(this.sharepointconnectdata.getconnectionstringforreading()); if (sql_string == "") { strsql = "select * list"; } else { strsql = sql_string; } this.usedsql_string = strsql; cmd = new system.data.oledb.oledbcommand(strsql, conn); ds = new system.data.dataset(); ds.locale = system.globalization.cultureinfo.installeduiculture; da = new system.data.oledb.oledbdataadapter(cmd); da.fill(ds); this.merge(ds.tables[0]); #endregion #region clearing ds.dispose(); da.dispose(); #endregion }
Comments
Post a Comment