Ian La Flair Ian La Flair - 1 month ago 13
C# Question

parse timespan to string c#

I got stuck on converting

timespan
, in sql server jamulai column datatype is
time


private void btntambah_Click(object sender, EventArgs e)
{
int kodejadwal = Int32.Parse(txtkode.Text);
string hari = txthari.Text;
TimeSpan jamulai = new TimeSpan (txtjam.Text);
string jamselesai = txtjam2.Text;

this.jadwalPraktekTableAdapter.Insert(hari, jamulai, jamselesai);
this.jadwalPraktekTableAdapter.Fill(healthy_CareDataSet.JadwalPraktek);
}

Answer
  1. Please read documentation for TimeSpan: Here
  2. And custom TimeSpan to string formatting : Here

Simply follow the documentation of TimeSpan and put in the format that you require.

Comments