473,395 Members | 1,915 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,395 software developers and data experts.

Dating Advice

So I like this girl and..

harrrranyway,

I have birth dates in a table stored as 11/07/1982 or 7/5/1974 etc.
Now there are 7150 records and I cannot really alter the date format
to conform with the mysql YYYY-MM-DD format. Reason being I need to
search by age, ie, BETWEEN 2 dates, which if they're in the DD/MM/YYYY
format it wont work.

Is there a way to :
a) easily change the format of the data in there
b) mysql has some sort of command telling it that the date is actually
in DD/MM/YYYY and to do its magic and work as if it was the norm.

I will be adding new entries to the data. If it's a) I can format the
date on the fly and input it into the database. If it's b) I will let
the data stay as it is

Help appreciated
Ry
Jul 17 '05 #1
9 1417
RelaxoRy wrote:
So I like this girl and..


My advise would be to bluntly ask het out for a nice romantic movie.
Maybe a good restaurant first?

Listen good to what she says, and give her a lot of attention.

Never try any funny touching the first date, no matter how difficult that is
for you.
Don't even try to kiss, except of course when she starts.

Call her the next day to tell her what a great time you had.
Do it again next week.

Good luck!

Regards,
Erwin Moller
Jul 17 '05 #2
RelaxoRy wrote:
So I like this girl and..

harrrranyway,

I have birth dates in a table stored as 11/07/1982 or 7/5/1974 etc.
Now there are 7150 records and I cannot really alter the date format
to conform with the mysql YYYY-MM-DD format. Reason being I need to
search by age, ie, BETWEEN 2 dates, which if they're in the DD/MM/YYYY
format it wont work.

Is there a way to :
a) easily change the format of the data in there
b) mysql has some sort of command telling it that the date is actually
in DD/MM/YYYY and to do its magic and work as if it was the norm.

I will be adding new entries to the data. If it's a) I can format the
date on the fly and input it into the database. If it's b) I will let
the data stay as it is

Help appreciated
Ry

I you want some help then give us a clue:-

1) What sort of table - FLAT ASCII file, MySQL table, Progresql table
etc etc
2) if its a table in a relational database do you mean you are storing
the date as a string ?
3) If its a date column in a relational database why can't you do the
age comparison you want to ?
Jul 17 '05 #3
.oO(RelaxoRy)
I have birth dates in a table stored as 11/07/1982 or 7/5/1974 etc.
Now there are 7150 records and I cannot really alter the date format
to conform with the mysql YYYY-MM-DD format.
Why not? There's no reason to not use native date formats if they are
available.
Reason being I need to
search by age, ie, BETWEEN 2 dates, which if they're in the DD/MM/YYYY
format it wont work.
With properly stored dates such calculations are quite easy.
Is there a way to :
a) easily change the format of the data in there
b) mysql has some sort of command telling it that the date is actually
in DD/MM/YYYY and to do its magic and work as if it was the norm.


Go for a). It's not trivial, but can be done with two queries. First you
have to change the values from DD/MM/YYYY to YYYY-MM-DD. Assuming the
field is of some string type, you can use MySQL's string functions to
split and reassemble the dates (might become a bit difficult if dates
are stored without leading zeros, make sure you backup your DB first).
After that you can change the column type to DATE with an ALTER query.

Micha
Jul 17 '05 #4
Yeah thats what i am led to believe. It's just a pain you know :) I
thought there was some function to make MySQL be able to read my
current data as it would a date field :)

Ohwell, time to play with strings!

Michael Fesser <ne*****@gmx.net> wrote in message news:<77********************************@4ax.com>. ..
.oO(RelaxoRy)
I have birth dates in a table stored as 11/07/1982 or 7/5/1974 etc.
Now there are 7150 records and I cannot really alter the date format
to conform with the mysql YYYY-MM-DD format.


Why not? There's no reason to not use native date formats if they are
available.
Reason being I need to
search by age, ie, BETWEEN 2 dates, which if they're in the DD/MM/YYYY
format it wont work.


With properly stored dates such calculations are quite easy.
Is there a way to :
a) easily change the format of the data in there
b) mysql has some sort of command telling it that the date is actually
in DD/MM/YYYY and to do its magic and work as if it was the norm.


Go for a). It's not trivial, but can be done with two queries. First you
have to change the values from DD/MM/YYYY to YYYY-MM-DD. Assuming the
field is of some string type, you can use MySQL's string functions to
split and reassemble the dates (might become a bit difficult if dates
are stored without leading zeros, make sure you backup your DB first).
After that you can change the column type to DATE with an ALTER query.

Micha

Jul 17 '05 #5
NC
RelaxoRy wrote:

I have birth dates in a table stored as 11/07/1982 or 7/5/1974 etc.
In a TEXT or VARCHAR field, I presume?
Now there are 7150 records and I cannot really alter the date
format to conform with the mysql YYYY-MM-DD format. Reason
being I need to search by age, ie, BETWEEN 2 dates, which if
they're in the DD/MM/YYYY format it wont work.
Ah, yet another early-stage design mistake that is proving
costly to fix later... :)
Is there a way to :
a) easily change the format of the data in there


No, but you can do something else. Let's say your birth date
column is named DOB. So you can:

1. Add a new column (type DATE) to your existing table and
name it, say, `born`.
2. Run something like this:

$select = 'SELECT id, DOB from mytable';
$result = mysql_query($select);
while ($record = mysql_fetch_array($result)) {
$id = $record['id'];
list($day, $month, $year) = explode('/', $record['DOB']);
$update = "UPDATE mytable SET born='$year-$month-$day' " .
"WHERE id=$id";
mysql_query($update);
}

3. Delete the old DOB column.
4. Rename `born` into `DOB`.

Cheers,
NC

Jul 17 '05 #6
On 23 Feb 2005 02:10:53 -0800, relaxory wrote:
It's just a pain you know :)


What, 2 simple queries?

alter table t1 add d2 as date;
update t1 set d2=concat_ws('-',right(d1,4),mid(d1,3,2),left(d1,2));
--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
Jul 17 '05 #7
NC
Ewoud Dronkert wrote:

What, 2 simple queries?

alter table t1 add d2 as date;
update t1 set d2=concat_ws('-',right(d1,4),mid(d1,3,2),left(d1,2));


The second one will probably make a mess because, according
to the original poster, leading zeros are not always present.
This is why I proposed a PHP script earlier...

Cheers,
NC

Jul 17 '05 #8
.oO(Ewoud Dronkert)
On 23 Feb 2005 02:10:53 -0800, relaxory wrote:
It's just a pain you know :)


What, 2 simple queries?

alter table t1 add d2 as date;
update t1 set d2=concat_ws('-',right(d1,4),mid(d1,3,2),left(d1,2));


It's not that simple if the dates are not stored with leading zeros, but
still possible with a single (but rather long) query. And if you do the
UPDATE first then you don't even need a new column, you can simply
change the type to DATE after the update.

Micha
Jul 17 '05 #9
On 24 Feb 2005 09:09:07 -0800, NC wrote:
The second one will probably make a mess because, according
to the original poster, leading zeros are not always present.


Ah yes sorry, glanced over his post and saw the "DD/MM/YYYY". A script
would be fine I guess. Or maybe:

alter t1 add d2 as date, i1 as tinyint, i2 as tinyint;
update t1 set i1=locate('/', d1), i2=locate('/', d1, 4);
update t1 set d2=concat_ws('-', substring(d1, i2+1), substring(d1, i1+1,
i2-i1-1), left(d1, i1-1));

Not tested; not sure if column values i1 and i2 can be used like this in
the 2nd update.

--
Firefox Web Browser - Rediscover the web - http://getffox.com/
Thunderbird E-mail and Newsgroups - http://gettbird.com/
Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Michael Lawrence | last post by:
I am looking to start up a comprehensive Adult dating website and I need pre-made PHP scripts to set up the back-end for this project. Preferably someone out there has a set of pre-made scripts...
7
by: fbionyourtail | last post by:
Been looking for a good PHP based dating script that is reasonably priced for a while. Several come close but are unfinished. I've already been burned by scripts almost done and then a complete...
4
by: marvado | last post by:
Hi, Does anybody know of a good and FREE dating/personals script? I need to put one on my website and looked everywhere for it. Only I found was AzDGDating, but doesn't cover many aspects of a...
1
by: magia | last post by:
Start or professionally redesign your dating website with MAGIA Dating Site Design (www.qesign.com/psd-dating.shtml). Online dating is an ever expanding industry! *** Very attractive stylish...
4
by: PD | last post by:
Hello everyone, I had posted a question regarding how to design high traffic fast dating website on different PHP groups. I got a lot of useful responses. I have added links to all the posts...
4
by: Abs | last post by:
Hi all, Wondering if you could help.. i'm looking for an ASP dating application for my site. Preferably classic ASP as i don't know ASP.net. Any pointers would be highly appreciated. Thanks!
4
by: Aaron | last post by:
AJ Dating Script is built with focus on increased ease of users and raised profits of webmasters. PHP/My SQL development are the cornerstone of our work. We also provide solutions in various...
3
by: Aaron | last post by:
AJ Dating is software for Dating sites which is immensely structured by AJ SQUARE INC. AJ Dating is a Dating Software Script. The user can search for users by using quick search, easy search and...
0
by: ahmik.flock | last post by:
AJ Dating is a Dating Software Script. The user can search for users by using quick search, easy search and advanced search. Quick search searches based on Gender and Age, Country living and photo....
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
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.