Mysql query to get data last week, next week, last year, next year, 30 days


TAHIR IQBAL NAJAM'S

To get data of yesterday (we use php function )
1. “select * from table where date = “.date(“Y-m-d”, strtotime(“-1 day”))
OR
2. “select * from table where date = NOW()-INTERVAL 1 DAY”

——————————————————————
To get data of tomorrow

1. “select * from table where date = “.date(“Y-m-d”, strtotime(“+1 day”))
OR
2. “select * from table where date = NOW()+INTERVAL 1 DAY”

——————————————————————
To get data of Last Week

“select * from tbl where date between NOW() – INTERVAL DAYOFWEEK(NOW())+6 DAY AND NOW() – INTERVAL DAYOFWEEK(NOW())-1 DAY”

View original post

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s