Datetime filter in datatable

1)Convert into String

     Method-1:       
        CultureInfo cul = new CultureInfo("FR-fr");
        string a1 = DateTime.Parse(txtFrom.Text, cul).ToString("dd/MM/yyyy 00:00:00");
        string a2 = DateTime.Parse(txtTo.Text, cul).ToString("dd/MM/yyyy 23:59:59");
  
  Method  - 2 :
       string fromdate = Convert.ToDateTime(txtFrom.Text).ToString("dd/MM/yyyy");

2)Convert String into Datetime

      DateTime from = Convert.ToDateTime(a1, System.Globalization.CultureInfo.GetCultureInfo("hi-IN").DateTimeFormat);
      DateTime to = Convert.ToDateTime(a2, System.Globalization.CultureInfo.GetCultureInfo("hi-IN").DateTimeFormat);
Previous Post Next Post