Author |
Topic |
rookie_sql
Constraint Violating Yak Guru
443 Posts |
Posted - 2007-03-13 : 10:30:28
|
Hi i have a feild in my .txt file that shows the date as "12-Mar-2007" so i set the column in the table to varchar and then i want to update my table and create a new column called new_date, based on the old date format "12-Mar-2007", but i want my new date format to be of datetime datatype. So i used this codeUPDATE tbl_Temp_outSET NEW_CREATED_DT = CONVERT(varchar, CREATED_DT, 101)But am getting a error on this Syntax error converting datetime from character string. |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-03-13 : 10:33:20
|
Create the new column NEW_CREATED_DT as datetimeUPDATE tbl_Temp_outSET NEW_CREATED_DT = CONVERT(varchar datetime, CREATED_DT, 101) KH |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-13 : 10:34:29
|
1. Don't use varchar to store dates2. Do date formatting on the front-endHarsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
rookie_sql
Constraint Violating Yak Guru
443 Posts |
Posted - 2007-03-13 : 10:55:44
|
Sorry i made a mistake in the code i had it the way you give it to meCONVERT(datetime, CREATED_DT, 101) i used the varchar as a work around.. but am still getting that error With the code below..My CREATED_DT column is data type varchar and i want my new colum NEW_CREATED_DT to be dada type datetime UPDATE tbl_Temp_outSET NEW_CREATED_DT = CONVERT(datetime, CREATED_DT, 101) |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-13 : 11:02:07
|
Make sure you have valid and consistent date format for all the values of CREATED_DT column using ISDATE() function.Select Created_DTfrom tbl_tempwhere isdate(Created_DT) = 0 Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
rookie_sql
Constraint Violating Yak Guru
443 Posts |
Posted - 2007-03-13 : 11:10:43
|
Here are the results am getting form that query they are not all consistent as you can see,I did a distinct query on the column and am getting back these numbers in the cloumn Created_DT, so this is were my probem is.. 66.6458.1584.205.8816.0814.5014.5014.5024.9323.99 |
 |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-03-13 : 11:12:51
|
Are these dates at all?Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
rookie_sql
Constraint Violating Yak Guru
443 Posts |
Posted - 2007-03-13 : 11:21:54
|
My extract has 190,000 rows in it and they are not dates, they look like the column before the date column in the extract, some how they are getting pulled into the wrong column am getting a error on the import it reads as follows "Too many columns found in the current row; non-whitespace characters were found after the last defined column's data. " the error is happening in rown 150,000 but i can see any difference in the row compared to the other rows.. |
 |
|
|