RE: [PHP-DEV] RE: [PHP-DB] PHP and MySQL queries...
| From: | Chris Newbill | Date: | Thu, 25 Oct 2001 17:49:50 +0000 |
| Subject: | RE: [PHP-DEV] RE: [PHP-DB] PHP and MySQL queries... | ||
| References: | 1 | Groups: | php.db php.dev |
| Request: | Send a blank email to php-dev+get-69012@lists.php.net to get a copy of this message | ||
-----Original Message-----
From: Tim Foster [mailto:tfoster@pdxinc.com]
Sent: Thursday, October 25, 2001 8:19 AM
To: php-dev@lists.php.net; php-db@lists.php.net
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:mike@invertedmind.com]
>> Sent: Wednesday, October 24, 2001 7:54 AM
>> To: php-dev@lists.php.net; php-db@lists.php.net
>> 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