Converting datetime format without using SAP RFC with C# -
i got problem when trying convert date-time format sap rfc.
i'm trying this:
string tmpdate = argdate.tostring("dd.mm.yyyy"); datetime date = convert.todatetime(tmpdate); irfcfunction saprateapi = null; saprateapi = _ecc.repository.createfunction("zrfc_cust_condition_rate"); saprateapi = createsaprateapi(saprateapi, argpartnersaptrancode, argcustsaptrancode, argmaterialcode, date); saprateapi.invoke(_ecc);
but getting error 'specified cast not valid'
consider using datetime.parseexact method.
// parse date , time custom specifier. string format = "dd.mm.yyyy hh:mm:tt"; datetime date; try { date = datetime.parseexact(argdate, format, cultureinfo.invariantculture); } catch (formatexception e) { throw new argumentexception("argdate", e); }
Comments
Post a Comment