Question : convert time and date format from asp.net to sql table

I insert timestamp from asp.net form to sql table. Problem is that time and date format that I insert looks like this 2009-12-23 13:10:16.000, and it should look like 2009-12-23 13:10:00.000 (without seconds and miliseconds). On sql table I have default getdate() and what I need to do is to have time inserted in sql table in format hh:mm. Where do I need to change date and time format? Thanks
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
Protected Sub Upisi_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Upisi.Click

        Dim connectionString As String = ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString
        Dim mySqlConnection As New SqlConnection(connectionString)
        Dim vrijeme2 As String
        vrijeme2 = Convert.ToDateTime(GridView1.SelectedRow.Cells(5).Text)

        If mySqlConnection.State = Data.ConnectionState.Open Then mySqlConnection.Close()
        mySqlConnection.Open()

        Dim strSqlInsert As String = "INSERT INTO Zahtjev_za_intervenciju (Prezime_ime, Opis_Lotus, Timestamp, Subject_Lotus, Atach_list, Lotus_Intranet) VALUES (@Prezime_ime, @Opis_Lotus, @Timestamp, @Subject_Lotus, @Atach_List, @Lotus_Intranet);"
        Dim mySqlCommand As SqlCommand = New SqlCommand(strSqlInsert, mySqlConnection)

        mySqlCommand.Parameters.AddWithValue("@Prezime_ime", GridView1.SelectedRow.Cells(3).Text)
        mySqlCommand.Parameters.AddWithValue("@Subject_Lotus", GridView1.SelectedRow.Cells(6).Text)
        mySqlCommand.Parameters.AddWithValue("@Opis_Lotus", txtBody.Text)
        mySqlCommand.Parameters.AddWithValue("@Timestamp", Convert.ToDateTime(vrijeme2))
        mySqlCommand.Parameters.AddWithValue("@Atach_List", txtAttach.Text)
        mySqlCommand.Parameters.AddWithValue("@Lotus_Intranet", "L")

        mySqlCommand.ExecuteNonQuery()
        mySqlConnection.Close()

    End Sub

Answer : convert time and date format from asp.net to sql table

use

mySqlCommand.Parameters.AddWithValue("@Timestamp", Convert.ToDateTime(vrijeme2).ToString("yyyy-dd-MM hh:mm"))

Thanks
Ajitha
Random Solutions  
 
programming4us programming4us