أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.
could you please explain it,
as per my understanding if you have mm/dd/yyy date with data type string then you just need to convert it to c# datetime data type and then just pass it through your procedure or yourquery
Simply create a custom method like this
/// <summary>
/// Converts string like "mm/dd/yyyy hh:mm" to Sql Date format
/// </summary>
/// <param name="date"></param>
/// <returns></returns>
public static DateTime ConvertStringtoDateTime(string date)
{
string sqldateformat = String.Format("{0}-{1}-{2} {3}", date.Substring(6, 4), date.Substring(3, 2), date.Substring(0, 2), date.Substring(11, 5));
DateTime dt = Convert.ToDateTime(sqldateformat);
return dt;
}
This can be easily achieved by
date.ToString("MM/dd/yyyy");
Easiest way would be using the inbuilt ToString function
DateTime myDateTime =DateTime.Now;string sqlFormattedDate = myDateTime.ToString("yyyy-MM-dd HH:mm:ss.fff");