How to convert time to datetime.
I am trying to send time to a datetime column.
So if I have 12:00 PM, how to convert to datetime , so i can send the value to the actual field in the database. I am trying to
insert the time values into the TimeFrom and TimeTo columns
Database columns,
ID, DateFrom, DateTo, TimeFrom, TimeTo
Loading
Mageshwaran RPosted Nov 23, 2019, 11:36 AM
Shebin babuPosted Nov 28, 2018, 12:30 AM
var dateTime = DateTime.ParseExact(dateStr, "H:mm", null, System.Globalization.DateTimeStyles.None);
VulpesPosted Dec 10, 2012, 2:45 PM
David SmithPosted Dec 10, 2012, 9:24 AM
Sandeep Singh ShekhawatPosted Dec 10, 2012, 8:52 AM
TimeSpan ts = new TimeSpan(24);
DateTime dt = Convert.ToDateTime(ts.ToString());
Response.Write(dt);
12/10/2012 12:00:00 AM
David SmithPosted Dec 10, 2012, 8:48 AM
from your logic below.
TimeSpan ts = new TimeSpan(12);
DateTime dt = Convert.ToDateTime(ts.ToString());
Sandeep Singh ShekhawatPosted Dec 10, 2012, 8:40 AM
TimeSpan ts = new TimeSpan(12);
DateTime dt = Convert.ToDateTime(ts.ToString());
Response.Write(dt);
It will give following output :
12/10/2012 12:00:00 PM
we can use dt variable for other operation ahead.
Anuja PawarPosted Dec 10, 2012, 8:02 AM