Page 1 of 1

Query for Today, Yesterday, Week, Month

Posted: Fri 10 May 2013 06:25
by DenisCGN
Hello,
I need some help. I am not so familiar with MySQL, so I bought Query Builder :-)
I need to have the following recordsets.

New Bands:
Today (only today)
Yesterday (without today)
Week (today till start of the week(monday))
Month (today till start of the current month)

I got the following field in my table to sort. onlineDate "yyyy-mm-dd 00:00:00" (datetime).

My wish will be, to have the exact week (starts on monday). So if today is wednesday it will only go back to monday of the current week. Same for month. from today back to the first day of the current month.

How does that work?

Cheers,
Denis

Re: Query for Today, Yesterday, Week, Month

Posted: Fri 10 May 2013 13:39
by DenisCGN
So I got the querys for

Today
SELECT * FROM artists WHERE DATE(artists.onlineDate) = CURDATE()

Current Week
SELECT * FROM artists WHERE WEEK(artists.onlineDate, 3) = WEEK(CURDATE(), 3)

Current Month
SELECT * FROM artists WHERE MONTH(artists.onlineDate) = MONTH(CURDATE())

Current Year
SELECT * FROM artists WHERE YEAR(artists.onlineDate) = YEAR(CURDATE())

But I need
Last Week, Last Month, Last Year

Any suggestions?

Re: Query for Today, Yesterday, Week, Month

Posted: Mon 13 May 2013 14:00
by alexa
Since the issue goes beyond the scope of our product, we suggest you to search for the answer in some other sources as we provide technical support only on our products.