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.
| Author |
Topic |
|
rsagona1
Starting Member
2 Posts |
Posted - 2009-08-20 : 11:25:01
|
| Good afternoon all, I'm in desperate need of help. I have a textbox with the text: "20-AUG-09", I would like to insert this into a datetime field. But it turns into '000:00:00:' so it is not working properly. I do not know how to convert it properly. Personally, I would rather just change the datatype in the db to string, but my boss will not allow me:-)Any assistance is greatly appreciated.Thank you,Rob |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2009-08-20 : 11:27:55
|
select DT=convert(datetime,'20-AUG-09')Results:DT-----------------------2009-08-20 00:00:00.000(1 row(s) affected) CODO ERGO SUM |
 |
|
|
rsagona1
Starting Member
2 Posts |
Posted - 2009-08-20 : 11:46:21
|
| Thank you Michael! Do I place this within the current insert statement like this? insert into tablename (date) values (select DT=convert(datetime,'20-AUG-09')) |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-08-20 : 12:32:59
|
No!insert into tablename (date) values (convert(datetime,'20-AUG-09')) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-08-21 : 01:47:27
|
| If the datatype of date is datetime, insert into tablename (date) values ('20-AUG-09')should work without errorMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|