473,394 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to put a Date into SQLServer (.NET)

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.

Feb 23 '06 #1
2 1774
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
"Des" <de*********@aol.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
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.

Feb 23 '06 #2
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
Des wrote:
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.


--
E-mail correspondence to and from this address may be subject to the
North Carolina Public Records Law and may be disclosed to third parties.

Feb 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Syed Mudussir Husain | last post by:
Hello, I am doing a very large web based database project. Over the period of 5 years, "more than 100, 000 Books" will be stored in a Database along with a LARGE amount of book attributes...
3
by: Paul Aspinall | last post by:
Hi Does anyone know the expected release date for .NET 2.0?? Thanks
3
by: Yannick | last post by:
Hi, I try to execute request on a ms-access database but I have a problem with date. the "myDate" field's format is "date/time" my request is: SELECT myCode, myStuff, myDATE FROM myTable ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.