Mysql obtains data from today, tomorrow, workday, weekend, this week, next week, and next month.

Source: Internet
Author: User
Mysql reads data from today, tomorrow, workday, weekend, this week, next week, and next month if ($ date !) {Switch ($ date) {date_add plus date_sub minus case today: $ where. ANDFROM_UNIXTIME (starttimefrom, % Y-% m-% d) curdate (); break; case tomorrow: $ where. ANDFROM_UNIXT

Mysql reads data from today, tomorrow, workday, weekend, this week, next week, and next month if ($ date! = '') {Switch ($ date) {// date_add plus date_sub minus case 'today ': $ where. = "AND FROM_UNIXTIME (starttimefrom, '% Y-% m-% D') = curdate ()"; break; case 'Tomorrow': $ where. = "AND FROM_UNIXT

Mysql obtains data from today, tomorrow, workday, weekend, this week, next week, and next month.
If ($ date! = '') {Switch ($ date) {// date_add plus date_sub minus case 'today ': $ where. = "AND FROM_UNIXTIME (starttimefrom, '% Y-% m-% D') = curdate ()"; break; case 'Tomorrow': $ where. = "AND FROM_UNIXTIME (starttimefrom, '% Y-% m-% D') = date_add (curdate (), interval 1 day)"; break; case 'workday ': $ where. = "AND dayofweek (FROM_UNIXTIME (starttimefrom) not in ()"; break; case 'weekend ': $ where. = "AND dayofweek (FROM_UNIXTIME (starttimefrom) in (1, 7)"; break; case 'Week': $ where. = "and yearweek (FROM_UNIXTIME (starttimefrom, '% Y-% m-% D') = YEARWEEK (now ()"; break; case 'Week': $ where. = "AND (FROM_UNIXTIME (starttimefrom, '% Y-% m-% D')> = SUBDATE (CURDATE (), DATE_FORMAT (CURDATE (),' % W ') -1) AND FROM_UNIXTIME (starttimefrom, '% Y-% m-% D') <= SUBDATE (CURDATE (), DATE_FORMAT (CURDATE (),' % W ') -7) "; break; case 'Next month': $ where. = "AND FROM_UNIXTIME (starttimefrom, '% Y-% m') = date_format (DATE_add (curdate (), INTERVAL 1 MONTH),' % Y-% m ')"; break; default :}}

?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.