-----Original Message-----
From: Tim Foster [mailto:[EMAIL PROTECTED]]
Sent: Thursday, October 25, 2001 8:19 AM
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Subject: [PHP-DEV] RE: [PHP-DB] PHP and MySQL queries...


>snip... (been doing VBScript on ASP for several years,
>tho).

I feel sorry for you. :)

>I'm curious...
>
>If you're going to store it as an integer, why not store "10/24/2001" as
YYYYMMDD
>(20011024). This gives you the added benefit of being able to have the db
sort your
>fields. This even works if you want to include the time with your date
(provided all dates
>in the field consistently contain the same *amount* of info). For example,
noon on
>Christmas will always be lower than noon of the following New Year ..as it
should be:
>
>YYYY/MM/DD                     20011225                < 20020101
>YYYY/MM/DD HH:MM               200112251200    < 200201011200
>YYYY/MM/DD HH:MM:SS    20011225120000  < 20020101120000

A better way to do integer date is a UNIX timestamp.  This will sort just as
easy as the method above.

By looking at the date() function you should be able to see immediately the
benefit in ease-of-use (not to mention portability in the DB) and formating
options available for the timestamp.

http://www.php.net/date

-Chris


>> -----Original Message-----
>> From: Mike Frazer [mailto:[EMAIL PROTECTED]]
>> Sent: Wednesday, October 24, 2001 7:54 AM
>> To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
>> Subject: Re: [PHP-DB] PHP and MySQL queries...
>>
>>
>> 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


-- 
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]

Reply via email to