query by date
Moderator: General Moderators
query by date
I wonder if it is possible to have a query that uses the date
e.g
table has a tv series list. lets say therre is a tv_id(primary key), tv_name, tv_episode, date
in php u query to show the whole list - select * from tvseries.
and it is displyed in a table.
what i want to know, if u update the epsiode so u had eps 1-10, but now u have 1-15, is it possible to highlight tv series that have been updated within 2 weeks?
Many thanks
e.g
table has a tv series list. lets say therre is a tv_id(primary key), tv_name, tv_episode, date
in php u query to show the whole list - select * from tvseries.
and it is displyed in a table.
what i want to know, if u update the epsiode so u had eps 1-10, but now u have 1-15, is it possible to highlight tv series that have been updated within 2 weeks?
Many thanks
Sure, it's possible.
60 secondind in 60 minutes in 24 hours in 14 days. 1209600 seconds in total. that should work 
Just as a quick note, try the databases forum for SQL stuff, it'll help you get a reply faster.
Code: Select all
SELECT * FROM table WHERE date = now()-60*60*24*14Just as a quick note, try the databases forum for SQL stuff, it'll help you get a reply faster.
Code: Select all
select * from TABLE_NAME where date=date_add(now(),interval -14 day)- coolpravin
- Forum Newbie
- Posts: 20
- Joined: Mon May 19, 2003 12:56 am
- Location: India
solution..
use this one
Here date is supposed to be name of the colum .
Warning :-
1)Do not use date as column name instead you can use ondate.
2)Always store date in Y-m-d format to database.
Code: Select all
SELECT * FROM tvseries WHERE TO_DAYS( NOW( ) ) - TO_DAYS(date ) <= 7Warning :-
1)Do not use date as column name instead you can use ondate.
2)Always store date in Y-m-d format to database.
Re: solution..
I always use the unix timestamp as a date in the database. Takes some formatting but it's very easy to work with when you have to calculate with dates.coolpravin wrote:use this oneHere date is supposed to be name of the colum .Code: Select all
SELECT * FROM tvseries WHERE TO_DAYS( NOW( ) ) - TO_DAYS(date ) <= 7
Warning :-
1)Do not use date as column name instead you can use ondate.
2)Always store date in Y-m-d format to database.