Agreed. This is especially useful when you need to conserve every byte you can; a timestamp of "10/24/2001" or something similar is going to take 10 bytes as a string and an indeterminate number of bytes for an actual timestamp because of system variations, whereas an integer value of 10242001 will take you 2-4 bytes depending on the type of int you declare. Not a lot of space, but assume for a second you have 30 fields in your database and 5 million rows...suddenly those 6-8 bytes have multiplied on this one field alone. Space and speed are important in DBs :)
Mike Frazer "Kodrik" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Why don't you let them enter it however they want in the form > mm-dd-yyyy > mm/dd/yy > > then in the php script that processes it, convert it with regulat expressions > to a timstamp and enter it in your database as an int. That's how I do it. > I don't understand the point in using the mysql timedate field format. > > Then on retrieval form the db, php can easily convert it to a nice format > with the date() function. > > > On Tue, 23 Oct 2001 10:52:41 -0600 Jason <[EMAIL PROTECTED]> wrote: > > > I am having a hard time setting up a form for users to enter a date in > > > the format of 00/00/0000 (of course they would use an actual date). My > > > form is as follows... > > > <form name="auth" method="post" action="search.php"> > > > <p>*I.E. - Format is 04/01/2001*</p> > > > <p>Search for Ads by date: > > > <input type="text" name="date"> > > > </p> > > > <p> > > > <input type="submit" name="login" > > > value="Submit"> > > > <input type="reset" name="reset" > > > value="Reset"> </p> > > > </form> > > > ================================================ > > > On my search.php page I have the following MySQL connection and search > > > parameters... > > > <?php > > > > > > mysql_connect ("db_hostname", "db_username", "db_password"); > > > > > > mysql_select_db ("db_name"); > > > > > > if ($date == "") > > > {$date = '%';} > > > > > > $result = mysql_query ("SELECT > > > fname,lname,address,city,state,zip,phonea,phone,email,crty,crnum,crmo,cry > > >r,w eeks,ogden,rock,logan,ipaddress,ad,total,num,date,time > > > FROM ads WHERE date LIKE '%$date%' LIMIT 0, 30 "); > > > $count = -1; > > > if ($row = mysql_fetch_array($result)) { > > > $count ++; > > > do { > > > echo "<B>Name: </B>"; > > > printf(mysql_result($result,$count,"fname")); > > > echo " "; > > > printf(mysql_result($result,$count,"lname")); > > > echo "<BR>\n"; > > > > > > echo "<B>Address: </B>"; > > > printf(mysql_result($result,$count,"address")); > > > echo "<BR>\n"; > > > > > > echo "<B>City: </B>"; > > > printf(mysql_result($result,$count,"city")); > > > echo "<BR>\n"; > > > > > > echo "<B>State: </B>"; > > > printf(mysql_result($result,$count,"state")); > > > echo "<BR>\n"; > > > > > > echo "<B>Zip: </B>"; > > > printf(mysql_result($result,$count,"zip")); > > > echo "<BR>\n"; > > > > > > echo "<B>Phone: </B>("; > > > printf(mysql_result($result,$count,"phonea")); > > > echo ") "; > > > printf(mysql_result($result,$count,"phone")); > > > echo "<BR>\n"; > > > > > > echo "<B>Email: </B>"; > > > printf(mysql_result($result,$count,"email")); > > > echo "<BR>\n"; > > > > > > echo "<B>Credit Type: </B>"; > > > printf(mysql_result($result,$count,"crty")); > > > echo "<BR>\n"; > > > > > > echo "<B>Credit Number: </B>"; > > > printf(mysql_result($result,$count,"crnum")); > > > echo "<BR>\n"; > > > > > > echo "<B>Credit Card Date: </B>"; > > > printf(mysql_result($result,$count,"crmo")); > > > echo " "; > > > printf(mysql_result($result,$count,"cryr")); > > > echo "<BR>\n"; > > > > > > echo "<B>Weeks: </B>"; > > > printf(mysql_result($result,$count,"weeks")); > > > echo "<BR>\n"; > > > > > > echo "<B>town1: </B>"; > > > printf(mysql_result($result,$count,"town1")); > > > echo "<BR>\n"; > > > > > > echo "<B>town2: </B>"; > > > printf(mysql_result($result,$count,"town2")); > > > echo "<BR>\n"; > > > > > > echo "<B>town3: </B>"; > > > printf(mysql_result($result,$count,"town3")); > > > echo "<BR>\n"; > > > > > > echo "<B>IP Address: </B>"; > > > printf(mysql_result($result,$count,"ipaddress")); > > > echo "<BR>\n"; > > > > > > echo "<B>Ad: </B>"; > > > > > > $ad[$count] = (mysql_result($result,$count,"ad")); > > > > > > $ad[$count] = ereg_replace ("&a&", "'", $ad[$count]); > > > $ad[$count] = ereg_replace ("&q&", "\"", $ad[$count]); > > > $ad[$count] = ereg_replace ("&p&", "%", $ad[$count]); > > > $ad[$count] = ereg_replace ("&bs&", "\\", $ad[$count]); > > > > > > > > > echo $ad[$count]; > > > echo "<BR>\n"; > > > > > > echo "<B>Total: </B>"; > > > printf(mysql_result($result,$count,"total")); > > > echo "<BR>\n"; > > > > > > echo "<B>Ad Number: </B>"; > > > printf(mysql_result($result,$count,"num")); > > > echo "<BR>\n"; > > > > > > echo "<B>Date: </B>"; > > > printf(mysql_result($result,$count,"date")); > > > echo "<BR>\n"; > > > > > > echo "<B>Time: </B>"; > > > printf(mysql_result($result,$count,"time")); > > > echo "<BR>\n"; > > > > > > } while($row = mysql_fetch_array($result)); > > > > > > } else {print "Sorry, no records were found!";} > > > > > > ?> > > > So far I have come to the conclusion that the input from the user is > > > probably where my problem is because I am assuming it is taking the "/" > > > in the date they enter and doing something I don't want it to. In any > > > event if someone could give me a clue as to how to resolve this issue it > > > would be greatly appreciated. > > > > > > > > > > > > -- > > > PHP Database Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > #-------------------------------------------------------# > > > > "Believe nothing - consider everything" > > > > Russ Michell > > Anglia Polytechnic University Webteam > > Room 1C 'The Eastings' East Road, Cambridge > > > > e: [EMAIL PROTECTED] > > w: www.apu.ac.uk/webteam > > > > www.theruss.com > > > > #-------------------------------------------------------# -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]