Insert into tablename(date_column) values (date('some date', format));
I however do not know how exactly to convert a character string to transact sql date. can someone please lead me in correct direction? Some documentation could also help.
Thanks
--Shilpa
No special functions needed. Just insert it as text:
CREATE TABLE test
(
dateValue datetime
)
go
INSERT INTO test
VALUES ('2006-01-01T00:00:00')
go
As for format of datetime values, there are many different ways to format a date, but really only a couple of good ways. Look up "Date Data Types" in books online. It explains it really well.
|||I am new to MS domain. Couldn't get to Books online.I attempted your suggested Insert statement. The problem is, my date format is different,
it appears as a 12 hour clock. The date shows as 05/12/2005 06:30:12 PM. The table design view shows it as general date. Could you suggest a format for this?
Thanks
S
|||INSERT INTO test
VALUES ('2006-01-01T00:00:00')
Sorry about the previous post. Your solution works without the T before time insertion.
Thanks,
S
|||
There is a copy of books online (not unsurprisingly) online:
http://msdn2.microsoft.com/en-us/ms130214(sql.90).aspx
You can also download it online. They update it quarterly, and this download is from April:
http://www.microsoft.com/downloads/details.aspx?FamilyID=be6a2c5d-00df-4220-b133-29c1e0b6585f&DisplayLang=en
No comments:
Post a Comment