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

Text field as date (MySQL)

P: n/a
Hello. I have a generic table used for many different generic
functions. the fields are mainly varchar's but one of these varchars
contains dates (in the format dd/mm/yyyy) for one reason or another.

My question is, can I perform a query on this table, using date
functions on this varchar field? I.e. search for the latest date?

Thanks, Chris

Aug 2 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On 2 Aug, 10:41, Chris Tate-Davies <christatedav...@gmail.comwrote:
Hello. I have a generic table used for many different generic
functions. the fields are mainly varchar's but one of these varchars
contains dates (in the format dd/mm/yyyy) for one reason or another.

My question is, can I perform a query on this table, using date
functions on this varchar field? I.e. search for the latest date?

Thanks, Chris
You can by using the STR_TO_DATE function, but it won't be very
efficient.

Aug 2 '07 #2

P: n/a
On 2 Aug, 10:41, Chris Tate-Davies <christatedav...@gmail.comwrote:
Hello. I have a generic table used for many different generic
functions. the fields are mainly varchar's but one of these varchars
contains dates (in the format dd/mm/yyyy) for one reason or another.

My question is, can I perform a query on this table, using date
functions on this varchar field? I.e. search for the latest date?

Thanks, Chris
BTH, this is NOT a php question.

You should post questions like this in comp.database.mysql
(the name of the group gives you the hint)

Aug 2 '07 #3

P: n/a
On 2 Aug, 11:01, Captain Paralytic <paul_laut...@yahoo.comwrote:
On 2 Aug, 10:41, Chris Tate-Davies <christatedav...@gmail.comwrote:
Hello. I have a generic table used for many different generic
functions. the fields are mainly varchar's but one of these varchars
contains dates (in the format dd/mm/yyyy) for one reason or another.
My question is, can I perform a query on this table, using date
functions on this varchar field? I.e. search for the latest date?
Thanks, Chris

BTH, this is NOT a php question.

You should post questions like this in comp.database.mysql
(the name of the group gives you the hint)

I am running the query in PHP. I wasn't sure if it would give me more
options.

But thanks for your help.

Chris

Aug 2 '07 #4

P: n/a
bill wrote:
Q1: Why the WHERE tempcol LIKE '%/%/%' clause ?
It would seem that it would work without it.
Q2: Why 3 %'s ?
A1: "WHERE tempcol LIKE '%/%/%'" means "where tempcol has the format
something-slash-something-slash-something". In other words, when tempcol
looks a bit like it could be a date.

A2: A date has three components: day, month and year.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.12-12mdksmp, up 43 days, 20:49.]

Command Line Interfaces, Again
http://tobyinkster.co.uk/blog/2007/0...nd-line-again/
Aug 3 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.