How to put a Date into SQLServer (.NET)

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.
 
V

vinu

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
 
T

Tom Williams

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top