By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,818 Members | 1,381 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,818 IT Pros & Developers. It's quick & easy.

Casting Text to Date

P: n/a
Hello,

MySQL Version = 3.23.46

I am working with a table which has a date field but type is varchar.
This cannot be changed. I don't have control over this.

I need to run a set of queries based on the date. for example, all
records with a given date, all records with date greater than a given
date etc.

Simply using "select * from media where event_> '09/09/2004'" will not
work.. because mySQL will do a text based comparison.

I tried CAST and CDATE but get errors. FOr example,

query = "SELECT CAST(event_date AS Date) FROM media where id = 15955"

Error : Error 1064: You have a syntax error in your SQL syntax near
'(event_date as date) from media where id=15955' at line 1

query = "select CDATE(event_date) from media where id = 15955"

Error : Error 1064: You have a syntax error in your SQL syntax near
'(event_date) from media where id=15955' at line 1

Any ideas?

Thx in advance.

Bijoy
Jul 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.