I've a textbox that displays the current time in this format "hh:mm:ss tt" but when it is save into the database it'll display the date and time together. So how do I save only the time into the database? My codes is as shown below:
txtTime.Text = DateTime.Now.ToLongTimeString()
Dim
parameterDateAs SqlParameter =New SqlParameter("@.Date_5",SqlDbType.DateTime)parameterDate.Value = txtDate.Text
objCommand.Parameters.Add(parameterDate)
I've tried using Format() but it still get the same results. Can someone help me out? Thanks!
The SQL Datetime datatype will always store a date portion. as effectively all you are doing is storing a time difference since an initial base date/time.
Perhaps change your SQL datatype to varchar and store the time as a string, or else use a constant date along with your time value (IE 1/1/1900).
Dave
No comments:
Post a Comment