PDA

View Full Version : Select record based on 'change' date


jacko201
03-22-2004, 04:01 PM
Hi,

I currently have a database containing a table with the following fields:
signid, sign_typ, changedate and time.

The 'changedate' field is the date on which the star sign changes and becomes 'active' until the next 'changedate' in the table. I am trying to search this field by a date the user enters and display the 'sign_typ'.


I am struggling to get this working and any help would be greatly appreciated.

Regards,
Paul

Nightfire
03-22-2004, 04:48 PM
SELECT sign_typ FROM table_name WHERE changedate='$dateentered'

That what you mean?

jacko201
03-22-2004, 05:00 PM
Hi,

Thanks for the reply.

The problem is not every date is listed in the table, only the date that the sign changes. e.g.

In the table the star sign changes to Aries on 23-03-1983 and the next listing is when it changes again on 07-04-1983 to Taurus.

So if a person entered 29-03-1983 as their d.o.b. the sign is Aries. How will i get it to select this from the database?

Regards,

Paul

jacko201
03-22-2004, 07:06 PM
Hi,

I have managed to solve the problem.

SELECT *
FROM `signs`
WHERE `Date` <= '$year-$month-$day'
ORDER BY `Date` DESC
LIMIT 0 , 1

regards,

Paul