Won't the getdate() function return a full timestamp?  I need the time
portion to always be midnight.

On Jan 12, 2:35 am, vinay kumar <[email protected]> wrote:
> rather than mentioning date u can use getdate() function sqlserver
>
> On Tue, Jan 12, 2010 at 2:26 AM, jtaylor <[email protected]> wrote:
> > I'm trying to insert a row into a SQL Server table but I keep getting
> > a "Conversion failed when converting character string to smalldatetime
> > data type." error.
>
> > This code works:
> >            sqlCmd = New SqlCommand("INSERT INTO tableName" _
> >                                            + " (colDate, colCount)" _
> >                                            + " VALUES ('1/9/2010
> > 12:00:00 AM', 1)" _
> >                                    , connSQL)
> >            sqlCmd.ExecuteNonQuery()
>
> > While this does not:
> >            sqlCmd = New SqlCommand("INSERT INTO tableName" _
> >                                            + " (colDate, colCount)" _
> >                                            + " VALUES ('@Date', 1)" _
> >                                    , connSQL)
> >            sqlCmd.Parameters.Clear()
> >            sqlCmd.Parameters.AddWithValue("@Date", "1/9/2010 12:00:00
> > AM")
> >            sqlCmd.ExecuteNonQuery()
>
> > What am I overlooking?
>
> > VB.NET & VS2005

Reply via email to