Code Comments
Programming Forum and web based access to our favorite programming groups.I'm trying to find a simple way of selecting records from a mysql database where the birthdate in the date field falls within the current wMon-Sunday, so today 20th November should match records from 15th to 21st Nov. I tried using the mysql w
function but this doesn't seem to work correctly for modes where w
starts Mondays. I do something like SELECT surname,forename FROM player_info WHERE w
(dob,3) = w
(curdate(),3) (dob is date field in the table) On 20/11 it selects records correctly On 21/11 it should select the same records as query above, as the w
number shouldn't alter until 22/11 which is the Monday. Is there another way of doing this ? A further complication is the mysql database is served on a US server, but I want all the calculations done wrt to GMT. Tony
Post Follow-up to this messageI realized my suggestion using w() is totally wrong. It will only work when using absolute dates. My requirement is only to match the days/months not years. So Mon->Sun will be different in each year for any particular day,month. So I need to find out which day of w
it is today, find out the date for last Monday, and the date for next Sunday, using GM dates, and select only dob records which fall within that period, ignoring the year. Thanks Tony "Tony Benham" <tonyb@kerrisway.freeserve.co.uk> wrote in message news:3094usF2tohcmU1@uni-berlin.de... > I'm trying to find a simple way of selecting records from a mysql database > where the birthdate in the date field falls within the current w
> Mon-Sunday, so today 20th November should match records from 15th to 21st > Nov. > I tried using the mysql w
function but this doesn't seem to work > correctly for modes where w
starts Mondays. > I do something like > SELECT surname,forename FROM player_info WHERE w
(dob,3) = > w
(curdate(),3) (dob is date field in the table) > > On 20/11 it selects records correctly > > On 21/11 it should select the same records as query above, as the w
> number shouldn't alter until 22/11 which is the Monday. > > Is there another way of doing this ? A further complication is the mysql > database is served on a US server, but I want all the calculations done wrt > to GMT. > > Tony > > > > > >
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.