Click to See Complete Forum and Search --> : MySQL date problem


intrivious
07-28-2006, 07:33 PM
I have one problem and two possible solutions... which one is best? The first one is not complete, but is it a better approach than the second?

=================================

I have a table named 'info'(simplified):

id | name | date
---------------
1 | chad | 20051014

This table means 'chad' owes money to a company on every '14'th of the month.
What would be the best query for saying:
I want to select everyone who owes me money from 20060710 through 20060720?

The solution is the query I am not sure how to construct.

OR

Would it be better/easier to change my table to
id | name | date | next_billing
-------------------------------
1 | chad | 20051014 | 20060714

then I can use in my sql query " WHERE next_billing >= 20060710 && next_billing <= 20060720" and just be sure to update the next_billing field to 20060914 after i run the query.

=============================================

Sorry if this is a bit confusing, any input is appreciated.
Thanks in advance,
Chad

aussie girl
07-29-2006, 12:48 AM
SELECT name, DATE_ADD('date_column', INTERVAL 31 DAY) AS "Next Billing" FROM info;
Have a read of some of the other Date/Time fuctions from the manual