visitor (0 QPoints)
  • FR
  • EN
  • NL
  • DE
  • ES
315 experts, 1193 registered users, 1659 questions already answered
European Experts Exchange, the very best site for high-quality IT solutions

New Improved Search!

 


05/10/2011 1h30 : Steve Jobs is dead, the father of Apple ][ is gone, we are all orphaned.

Databases :: MySql :: Querys for the past week/day using Timestamp field...?


By: Squibi U.S.A.  Date: 16/01/2003 00:00:00  English  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 English  Type : Comment
try :

"and date_field > curdate() - 7"
By: VGR Date: 16/01/2003 19:53:00 English  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

EContact
browser fav
page generated in 298.813100 milliseconds

Why Google AdSense ads ?

compteur
 Ranking-Hits PageRank for this page