Mysql obtains the first day of the quarter, the first day of the month, and the first day of the week.
On the first day of this quarter, you can convert the string to the date. There are many methods, including aliases (synonyms) of the same function. For example, CURDATE (), CURRENT_DATE (), CURRENT_DATE, NOW, and so on can all return the same day
Mysql tutorial> select CURDATE (), ELT (QUARTER (CURDATE ()),
-> Year (CURDATE () * 1000 + 0101,
-> Year (CURDATE () * 1000 + 0401,
-> Year (CURDATE () * 1000 + 0701,
-> Year (CURDATE () * 1000 + 1001) as firstDayofQ;
+ ------------ + ------------- +
| CURDATE () | firstDayofQ |
+ ------------ + ------------- +
| 2009401 |
+ ------------ + ------------- +
1 row in set (0.00 sec)
Mysql>
Use mysql statements to obtain the first day of the quarter
The first day of this month,
Date (
Concat (year (curdate (), '-', month (curdate (), '-', '1 '))
The first day of this week
Curdate ()-
WEEKDAY (curdate ())
Use mysql statements to obtain the first day of the quarter
Date (
Concat (year (curdate ()),'-',
If (quarter (curdate () =, 10 ))
Use the mysql statement to obtain the first day of the quarter:
Optimization:
Date (
Concat (year (curdate (), '-', elt (quarter (curdate (),), '-', 1 ))
The first day of this week
Date_add (date ('2017-5-29 '), INTERVAL-weekday ('2017-5-29') day)
SQL statement for mysql to obtain the published file content on the current day
SELECT * FROM 'p8 _ memberdata' where regdate BETWEEN (UNIX_TIMESTAMP (NOW ()-86440) and now ()
SELECT * FROM 'p8 _ memberdata' WHERE DATE_FORMAT (FROM_UNIXTIME (regdate), '% Y-% m-% D') = DATE_FORMAT (NOW (), '% Y-% m-% D') order by uid desc