Previous Thread
Next Thread
Print Thread
Rate Thread
#266897 01/14/2004 5:21 AM
Joined: Feb 2002
Posts: 11
Newbie
Newbie
Offline
Joined: Feb 2002
Posts: 11
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

Sponsored Links
tiendoan #266898 01/14/2004 2:52 PM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
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.

Daine #266899 01/15/2004 7:45 AM
Joined: Feb 2002
Posts: 11
Newbie
Newbie
Offline
Joined: Feb 2002
Posts: 11
Anyway think its no good idea to store date in varchar.
So How can i convert my date field to new format ?

tiendoan #266900 01/15/2004 11:00 AM
Joined: May 1999
Posts: 3,039
Guru
Guru
Offline
Joined: May 1999
Posts: 3,039
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.


UBB.threads Developer
Sally #266901 01/19/2004 3:42 AM
Joined: Feb 2002
Posts: 11
Newbie
Newbie
Offline
Joined: Feb 2002
Posts: 11
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.

Sponsored Links

Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
isaac
isaac
California
Posts: 1,157
Joined: July 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)