Hi need your help mga master
I have a table 'date_posted' which is in datetime, i want to get the latest records within the week starting from the current date. unsaon ni nako pag query?
thanks
Hi need your help mga master
I have a table 'date_posted' which is in datetime, i want to get the latest records within the week starting from the current date. unsaon ni nako pag query?
thanks
Last edited by harvz86; 11-08-2010 at 06:36 PM.
Programmatically generated na lang bro ang to and from.
Kung pseudo code...
get current date as current...
get the date seven days before as start...
query dayon ka...
select * from sampletable
where date_posted between (start) and (current)
order by date_posted desc
^^^ Tumpak
If your mysql version is Mysql 5.0.19 up, you can do it this way bro
"select * from myTable where date_posted between date_sub(now(), INTERVAL 1 WEEK) and now() order by posted_date desc"
or if 5 below:
"select * from myTable where date_posted between date_sub(now(), INTERVAL 7 DAY) and now() order by posted_date desc"
Last edited by psyche54; 11-09-2010 at 11:02 AM.
Similar Threads |
|