RE: Date Handling Recommendations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> Hi all,
> I need to manage some records with dates. mmddyyyy
> 
> I'm putting select options breaking the three up in numeric pull
> downs. no problem gathering and storing the data in my mysql db as
> integers then posting them for existing records etc. i know their is a
> datetime datatype but it doesnt seem easier to use this data type than
> using integers...any tips or routines for handling this?


I guess this is my day to be dense, but I don't really understand the
question.  One part I think I understand is that you don't see the benefit
to using the DATE datatype to store your dates.  The DATE datatype allows
you to do many things with dates that would be difficult storing them as
integers. 

For instance, what would you have to do to get the day of the week for a day
66 days prior to the stored date?  If your date was stored in a DATE field,
all you would have to do is:

$result=mysql_query("SELECT DATE_FORMAT(DATE_SUB(`stored_date`, interval 66
days) ,"%W") from tablename where...");
$row=mysql_fetch_row($result);
echo "The day if the week is ".$row[0];

...if your dates are stored in integer fields, how would you easily come
about a similar result?

JM

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux