wrong datetime format in sql
when i send datetime in c# it look like {01/02/2018 12:10:20 PM} and when convert xml it look like 2018-01-02T12:10:20+06:00 and when save it to sql database it look like 2018-01-02 06:10:20.000 but i need 2018-01-02 12:10:20
Answers (2)
0
Hi Rathrola,
code in c#
public JsonResult Insert(List<Voucher>vl)
{
DataSet vlistDs = new DataSet();
vlistDs.DataSetName = "Ds_Voucherlist";
string json = JsonConvert.SerializeObject(vl);
DataTable dtl = JsonConvert.DeserializeObject(json);
dtl.TableName = "Dt_VoucherList";
vlistDs.Tables.Add(dtl);
string dsData = vlistDs.GetXml();
int success = _iInsert.InsertVoucher(dsData);
return Json(success, JsonRequestBehavior.AllowGet);
}
public class Voucher
{
public decimal Amount { get; set; }
public string ChequeDate { get; set; }
public string ChequeNo { get; set; }
public bool IsAgainstCheque { get; set; }
public bool isCash { get; set; }
public string Name { get; set; }
public string particular { get; set; }
public DateTime VoucherDate { get; set; }
public string VoucherNo { get; set; }
}
Thanks
0
Hi Pulak,
Can you share code snippet of saving date to db ?
Regards,
Rathrola