recordset - MySQL results yesterday, last week, last month and last year -


my datefield (artists.onlinedate) yyy-mm-dd hh:mm:ss

right got:

-- today select * artists date(artists.onlinedate) = curdate() -- current week select * artists week(artists.onlinedate, 3) = week(curdate(), 3) -- current month select * artists month(artists.onlinedate) = month(curdate()) -- current year select * artists year(artists.onlinedate) = year(curdate()) 

but need exact: yesterday, last week, last month, last year

i try explain. if got wednesday, , use select * artists date(artists.onlinedate) = curdate(), monday wednesday.

i have monday sunday of last week. calendar week before.

and same month , year.

i thins sub_date not right way.

any suggestions?

ok found looking at:

mysql query select data last week?

select * testwoche   week (datum, 3) = week(current_date, 3) - 1     , year(datum) = year(current_date) order datum desc 

same month

select * testwoche   month (datum) = month(current_date) - 1    , year(datum) = year(current_date)  order datum desc 

this gives last week monday sunday , last month

thanks helping!


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -