Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 how to insert into a field (type is Datetime)

Author  Topic 

lkt
Starting Member

1 Post

Posted - 2003-06-18 : 23:34:48
help me, please!
I want to insert into a field (type is Datetime) from ASP to SQL Server, when input 19/6/2003 on page ASP and submit, but In table on Database SQL server only display 01/01/1900.How to submit 19/6/2003 then display 19/6/2003!

Thank you very much!"

chadmat
The Chadinator

1974 Posts

Posted - 2003-06-19 : 00:10:16
By default the date 19/6/2003 makes no sense. It is the 19th month which of course doesn't exist.

Displaying the date is easy. It is just a matter of converting it to the proper format.

ex. SELECT Convert(varchar(10), MyDate, 103) FROM MyTable

What collation is your server installed with?

-Chad

http://www.clrsoft.com

Software built for the Common Language Runtime.
Go to Top of Page

mr_mist
Grunnio

1870 Posts

Posted - 2003-06-19 : 03:57:03
If you insert your data as YYYYMMDD then sql server will always store it correctly, regardless of regional settings. The best way to input a date from an ASP page, in my humble opinion, is to use pull down menus (listboxes) and not free text input.

-------
Moo.
Go to Top of Page
   

- Advertisement -