Re: Date Comparison Question

From: Date: Tue, 30 Jan 2001 08:21:42 +0000
Subject: Re: Date Comparison Question
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-37264@lists.php.net to get a copy of this message
> The display works great until I get to the end of the month (like now). I > have separated the date as three rows in my dB (msg_year, msg_month and > msg_day) Don't do that. :-^ > As soon as the next month starts, then I get 4 events. > > I know exactly what's wrong, But my non-programmer limitations are coming to > light and I have absolutely no clue what to do next or how to proceed. Any > direction will be extremely appreciated. Database developers spent years getting date-time calculations to work, and you went and tried to out-think them... :-) You *might* be able to use some sort of mktime() function in your database package, and build up a date from your existing fields before you compare. But it would probably be easiest all around to convert your three fields into a single date field. Then, you can just use < and > and = on your dates, as well as some data arithmetic functions like date_add. Caveats: The date field may have limitations such as "only dates between 1/1/1970 and 3/17/2038" Check your database documentation... MySQL http://mysql.org PostgreSQL http://postgresql.org -- Visit the Zend Store at http://www.zend.com/store/ Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm

« previous php.general (#37264) next »