March 24th, 2000, 04:55 AM
I'm trying to get a month-on-month function for displaying data from a mysql-db.
The table i want to extract info from, stores urls and timestamps.
let's say today is the 15th of march, then i want to display all data timestamped from the 1st of march to the 15th of march, and all data from the 1st of february to the 15th of february.
the dates are stored like "YYYY-MM-DD hh:mm:ss"
i'm lost, totally lost...
can any1 help me?
March 24th, 2000, 08:27 AM
I'm a big fan of MySQL's to_days() function although there are other ways to do it, I'm sure.
// assume timestamp column is called 'stamped'
>SELECT * FROM table_name
>WHERE to_days(stamped) BETWEEN
// or substitute (to_days(now())); for the last line if today is the upper end of the date limit you want to check.
Check out the online ref manual for information on the to_days() function as well as other date-time arithmetic functions -> very valuable.
Hope this is what you're looking for.
March 24th, 2000, 09:05 AM
it might be of use ...
how does it handle leap years and stuff?