Using DateTime-fields in an SQL string is not difficult. Therefore the DateTime format must be 'YYYY-MM-DD HH:mm'.
For Example:
"Select * from MyTable Where MyDateTimeField > '2007-01-01 12:00'"
For converting a .NET DateTime object to a valid SQL-compliant string using C# the following code snippet can be used:
public static string ConverteerDatum(DateTime in_Datum)
{
return = in_Datum.Year + "-" + in_Datum.Month + "-" + _
in_Datum.Day + " " + in_Datum.ToLongTimeString();
}
Labels: Convert, DateTime, SQL
Posted by Xander Zelders

0 Comments:
Post a Comment
<< Home