UBB.Dev
Posted By: kit400 Birthday - 01/14/2004 12:21 PM
Whay is the U_Birthday field in db is varchar ?

Meny meny tims ago i've writen hack for birthday but i used date type. Now i trying to convert ... With data i can easy get statistics of users' age groups like

teenagers - 30% - 555 user
from 20 to 25 - 25% - 500 users
from 25 to 30 ...
etc

And meny other good things...

I think its better to use date type for stosring date in DB

sorry for my english
Posted By: JoshPet Re: Birthday - 01/14/2004 9:52 PM
He's got it that way so that the field is indexed for month and day first, so that it can grab the stuff efficiently for the calendar.... vs a real date field where the year would come first.
Posted By: kit400 Re: Birthday - 01/15/2004 2:45 PM
Anyway think its no good idea to store date in varchar.
So How can i convert my date field to new format ?
Posted By: Rick Re: Birthday - 01/15/2004 6:00 PM
If you convert your date you will break the code that checks for birthdays on given dates for the front page and the calendar. The reason it isn't stored in a timestamp is if it was every date would need to be converted to min and max seconds for that day and then a comparison done to see what birthdays fall within that range. Not extremely efficient. With it being stored in the format it is, we can just do a LIKE comparison that uses the index properly.

So, you'll need to keep in mind if you convert it there will be alot of code that will need to be changed.
Posted By: kit400 Re: Birthday - 01/19/2004 10:42 AM
i mean to convert it ftom my date type to your varchar.
I've done with one query

Update w3t_Users set U_Birthday =DATE_FORMAT(U_BDay, '%c/%e/%Y')

btw once else example of manipulation with date(). Try to do something like this with varchar.

sorry for my english.
© UBB.Developers