473,396 Members | 1,724 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Text field as date (MySQL)

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
4 3035
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: PhilM | last post by:
Kindly break out the 4x2 and bring me to my senses. I seem to have gotten myself totally confused with php.net, mysql.org pages on dates etc, as well as groups.google. Could someone explain,...
6
by: James Turner | last post by:
I am trying to store formatted text (windows format) into a MySQL database and then retrieve it. The field in the database is a varchar. I cut and paste the test into a form field formatted, then...
2
by: C.F. Scheidecker Antunes | last post by:
Hello all, I wonder if is there any way to select from a table all the records which has a Date Field that is at least five minutes old? In other words, I have a table with a date field and I...
3
by: usenet | last post by:
I have inherited a table where date information was saved from PHP as a VARCHAR. (Sigh.) This means that the so-called date fields look like this : August 1, 2005, 9:09 am EDT October 13, 2004,...
6
by: Kevin Chambers | last post by:
Hi all-- In an attempt to commit an Access MDB to a versioning system (subversion), I'm trying to figure out how to convert a jet table's metadata to text, a la SaveAsText. The end goal is to...
2
by: hph | last post by:
Please be gentle; I am a relative newbie for php/MySQL, and most of what I am doing is based on being self-taught using someone else's well-written code, and my own googling the answers to my...
11
by: walterbyrd | last post by:
My MySQL table has a field that is set as type "date." I need to get today's date, and insert it into that field. The default for that MySQL field is 2006-00-00. I know about the date()...
8
by: libsfan01 | last post by:
how can i use regular expressions to ensure a mysql format date entry in a text field? thanks marc
12
by: mantrid | last post by:
Hello Can anyone point me in the right direction for the way to read a text file a line at a time and separate the fields on that line and use them as data in an INSERT to add a record to a mysql...
8
by: Tony B | last post by:
I have a string in a existing php script which is in the form "dd/mm/yyyy" and I need to convert it into a suitable format for mysql which is "yyyy-mm-dd" Is there a neat way of doing this in php ?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.