Databases :: MySql :: Querys for the past week/day using Timestamp field...? |
|||
| By: Squibi |
Date: 16/01/2003 00:00:00 |
Points: 50 | Status: Answered Quality : Excellent |
|
Hi, I would like to perform queries which lookup data from the past week,day,month etc. Is this possible? I have a timestamp field so the data does all have a relevant date. The timestamp field is in the format "09/01/2003 17:53:46" The query I want to use it on is... SELECT page ,COUNT(*) AS indexCount FROM usertrack WHERE page="/index.cfm" /*****AND ONLY FOR RECORDS OF THE PAST WEEK*****/ GROUP BY page; Thanks inadvance I don't know if this is possible... |
|||
| By: sumotimor | Date: 16/01/2003 00:33:00 | Type : Comment |
|
| try : "and date_field > curdate() - 7" |
|||
| By: VGR | Date: 16/01/2003 19:53:00 | Type : Answer |
|
| I prefer to use "+|- INTERVAL x [DAY|MONTH|WEEK|YEAR]" like in SELECT ... WHERE ... AND yourdatetimemarker >= now() - INTERVAL 7 DAY;" // add ORDER BY etc if necessary |
|||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








