Are you wanting the logic at the DB level or the application (PHP) level?
If PHP, you can use a combination of the date() function and the strtotime()
function.
Without testing, I think something like date('Y-m-d', strtotime('+14 days'))
should return a date two weeks in the future.
Thanks,
Nathan.
http://kturl.com/blog
-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf
Of Super Steve
Sent: Wednesday, 23 June 2010 4:09 p.m.
To: NZ PHP Users Group
Subject: [phpug] Handling Anniversarys
I have a need to record an anniversary date with just a day and month
(year isn't important so I don't need to record it).
I'm using MySQL 5.0.26 and was wondering what the best way is to store
the anniversary and then do queries on it.
The query I need to do is to select all records that have an
anniversary date 2 weeks in the future.
Should I split the anniversary date into two numeric fields or somehow
keep it as one? Maybe convert it to some sort of "day of year" number
(what about leap years?)?
I will be using a form to get the anniversary, and also to allow
editing of the anniversary. I was thinking of having two select
lists, one for day (0 - 31) and one for month (Jan - Dec).
Any ideas on the best way to handle this?
--
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
--
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]