How to put a Date into SQLServer (.NET)

  • Thread starter Thread starter Des
  • Start date Start date
D

Des

I have tried various configurations of putting todays date into an sql
Server 2000 database
The field is set to Datetime Length(8) it displays 01/01/1900 after
insertion

What I have is

Dim Created as date
Created = Convert.ToDateTime(Now()).ToString("dd-MM-yyyy")

SQL = "INSERT INTO Baskets VALUES (" & iUser & " , " & Created)

it displays 01/01/1900 after the record has been inserted.
 
hi,

Specify default value of Baskets table's date column as getDate() (SQL
Server function)
Then you don't need to pass the date value to SQL Server. SQL server will
insert today's automatically

vinu
 
You are concatenating a date with a couple of strings. Maybe Created
should be a string also.

Dim created As String
created = Now().ToString
Label1.Text = created
'or
Label1.Text = Now().ToShortDateString

Tom
 
Back
Top