Hi I am executing a stored procedure from the function below. On all the dates, I am getting time at the end 19:12:2012 00:00:00 in the datatable. The column is defined as Date in the database and return as Date in the SP. Why am I getting 00:00:00 at the end of the dates?
Thanks.
Sample code.
Dim dt As New DataTable
Dim da As New SqlDataAdapter
Dim con As New SqlConnection(_conString)
Dim SelectCommand As New SqlCommand()
With SelectCommand
.Parameters.Add(New SqlParameter(_strAcademicYear, SqlDbType.Int))
.Parameters(_strAcademicYear).Value = _AcademicYear
.CommandText = "[Teacher].[GetDate]"
.CommandType = CommandType.StoredProcedure
.Connection = con
End With
da.SelectCommand = SelectCommand
con.Open()
da.Fill(dt)
con.Close()
Because in your datatable, it’s a
DateTime. There is no CLR type for just date. The default time for a non-time-specified date is midnight – 00:00:00.You can use column data formatting for your gridview, I’m assuming – haven’t worked with one in ages – to properly output the data you want to display.
Something like
and replace the format string with whatever you’d like it to look like, of course. =)
(Tag updated as per comment by chridam)