I have string time. lets say '06:35 PM'. I want to convert the string to DateTime. The date must be current time(the day as they input the time).
I did
string times = endTime;
DateTime dt;
(DateTime.TryParseExact(times, "YYYY-MM-dd HH:mm tt", CultureInfo.InvariantCulture,DateTimeStyles.None, out dt))
But it didn't works. it make a null value. because when I try to put the result on label, the label did not show anything. and also I have been try
var date = DateTime.Parse("06:45 AM");
Console.WriteLine(date);
But it didn't works too and it makes an error.
ERROR System.Data.SqlClient.SqlException (0x80131904): The conversion of a varchar data type to a datetime data type resulted in an out-of-range value. The statement has been terminated. "
How do I convert it ?