One way is save the dates as time stamps Then you calculate the number of seconds in two weeks and use that to select dates two weeks in the future.
If yoru dates are stored as date or datetime then use the mysql DATEDIFF function. See the manual on the mysql website. Cheers Hamilton -----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]
