MySQL obtain first day of the month, the first day of the next month, etc.

  1. the SELECT CURDATE (); - get the current date
  2. the SELECT LAST_DAY ( CURDATE ()); - obtaining the last day of the month.
  3. SELECT DATE_ADD ( CURDATE (), interval The - Day ( CURDATE ()) + . 1 Day ); - obtaining a first day of the month
  4. SELECT DATE_ADD ( CURDATE () - Day ( CURDATE ()) + . 1 , interval The . 1 month The ); - obtaining a first day of the next month
  5. SELECT the DATEDIFF ( DATE_ADD ( CURDATE () - Day ( CURDATE ()) + . 1 , interval The . 1 month The ), DATE_ADD ( CURDATE (), interval The - Day ( CURDATE ()) + . 1 Day )) from Dual ; - Get current month number of days

Guess you like

Origin www.cnblogs.com/lixiaozhi/p/11535160.html