Hi,
My application needed that:
i have no of topics (100 topics) shows after the login (by usder id and password),
my topics enabled by date, now i want to display the topic of the day after topic name by seeing the date, if any topic found on the system date then AFter topic name DIsplay a text that "New Topic" if not found any topic in the date then display the just less date from the current date as the new topic, here is the problem my dates are not in the Serial such that 2009-10-11, 2009-10-12, 2009-10-13... etc, my dates are 2009-10-11, 2009-10-15, 2009-10-16,2009-18... etc. i want the just less date from the system date.
if i fire the Query
SQL >> select * from time_table where time_table_date<'2009-11-2009';
after execute this Query this gives me all the less date data from the System date, but i want just immediate less date data.
Please help me out i m stuck in the code, and i have written many line codes but not found the solutions..................... Please
Thanks in ADV.
PLease Help.....
Moderator: General Moderators
- angelicodin
- Forum Commoner
- Posts: 81
- Joined: Fri Nov 13, 2009 3:17 am
- Location: Oregon, USA
Re: PLease Help.....
Hi Pirontech. I'm having a hard time understanding what you are asking but I'll give it a shot.
If I understand right you want to compare a date(sql) with the current date(php) right? And your date field in your table is a different format that normal? my question with that, is that field a VARCHAR or something like it, or is it DATETIME?
If I understand right you want to compare a date(sql) with the current date(php) right? And your date field in your table is a different format that normal? my question with that, is that field a VARCHAR or something like it, or is it DATETIME?
Re: PLease Help.....
Actualy a have the date in the format 'YYYY-MM-DD' ex 2009-10-25angelicodin wrote:Hi Pirontech. I'm having a hard time understanding what you are asking but I'll give it a shot.
If I understand right you want to compare a date(sql) with the current date(php) right? And your date field in your table is a different format that normal? my question with that, is that field a VARCHAR or something like it, or is it DATETIME?
i want just less date from the system date Ex. Today is 2009-11-18 now i want just less immediate date,
but my data base do not have the date in serial no ex
2009-11-15
2009-11-16
2009-11-17
2009-11-18
2009-11-19
my db have the date Ex.
2009-11-14
2009-11-16
2009-11-16
2009-11-18 -- Todays Date System Date
2009-11-21
now i want just immediate less date from the system date
But how to find it
MY SQL >> select * from table Name where date < '2009-11-18' ;
but it gives me this result :
2009-11-14
2009-11-16
2009-11-16
but i only want : 2009-11-16 but how please help me out.
is it sufficient ?
Plzzz
- angelicodin
- Forum Commoner
- Posts: 81
- Joined: Fri Nov 13, 2009 3:17 am
- Location: Oregon, USA
Re: PLease Help.....
I think I get you now. Try this:
SELECT * FROM `table_name` WHERE date(date_field) < CURdate() ORDER BY `table_name`.`date_field` DESC LIMIT 0, 1 ;
SELECT * FROM `table_name` WHERE date(date_field) < CURdate() ORDER BY `table_name`.`date_field` DESC LIMIT 0, 1 ;