convert varchar to date

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 ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-21-2007
Steve
 
Posts: n/a
Default convert varchar to date

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.

Reply With Quote
  #2 (permalink)  
Old 12-21-2007
Captain Paralytic
 
Posts: n/a
Default Re: convert varchar to date

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.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 07:03 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0