This is a discussion on convert varchar to date within the MySQL Database forums, part of the Database Forums category; I have a table that imports data from text files, and the dates come in as YYYYMMDD into a varchar ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I have a table that imports data from text files, and the dates come
in as YYYYMMDD into a varchar column. I need to compare those dates to a column in an existing table that is date format YYYY-MM-DD I was thinking that CONVERT(DATETIME,temp_table_field) = 'existing_table_field' but keep getting a syntax error. |
|
|||
|
On 21 Dec, 14:23, Steve <steve.lo...@gmail.com> wrote:
> I have a table that imports data from text files, and the dates come > in as YYYYMMDD into a varchar column. > > I need to compare those dates to a column in an existing table that is > date format YYYY-MM-DD > > I was thinking that CONVERT(DATETIME,temp_table_field) = > 'existing_table_field' but keep getting a syntax error. Is the column in the existing column a date column or a char/varchar column containing a string representation of a date? If it is the former, the date column does not have a format of YYYY-MM- DD, it has MySQL's internal date format. It can however be viewed in any number of formats. |