Many times, we in the MySQL database query when we want to deal with time, such as formatting or other operations, this way to avoid the re-processing, and MySQL has a lot of time to deal with the function, today simple to do a small summary, for
Very many times. When we are querying the MySQL database, we want to process the time, for example, format or other operation, this way to avoid the processing. And MySQL also has a lot of time aspects of the processing function, today simple to do
Sysdate[Function]: returns the current date. [Parameter]: No parameter, no brackets [Return]: Date [Example] select sysdate hz from dual; return:
Add_months (d1, n1)[Function]: return the new date after the date d1 plus the n1 month. [Parameter]: d1,
Select date_sub (now (), interval 1 month) current time of last month today select unix_timestamp (date_sub (now (), interval 1 month) current time of last month today (timestamp) select date_sub (date_format (now (), '% Y-% m-% d 08:00:00'),
[SQL chapter -- DATABASE/EVENTS], -- databaseevents[SQL chapter] [SQL statement sorting: -- Based on MySQL5.6] [sorted: DATABASE/EVENTS] [will be improved] directory:1. Data Definition Statements:1.1 create database, alter database, show databases 1.
Article Source: http://www.cnblogs.com/zfc2201/p/3284965.htmlDate formatting: Alter session set nls_date_format= ' Yyyy-mm-dd hh24:mi:ss dy 'Note: The HH24 format cannot be set to am pm on PM Indicatorsysdate"function": Returns the current date.
Problem background:
Suppose the MySQL database has a membership table Vip_member (InnoDB table), the structure is as follows:
When a member wants to renew a member (only 1 months, 3 months, or 6 months), the
Requirements Description :In the process of using MySQL, you need to calculate the date, for example, a date plus a few days, a few hours, etc.In this record, the use of the Date_add () function.Operation Process :Date_add () function
SysdateFeature: Returns the current date."Parameters": no arguments, no parentheses"Back": Date
2Add_months (D1,N1)"Function": Returns the new date after the date D1, plus N1 months."Parameters": D1, Date type, N1 digital type"Back": Date
Because the project needs to create a timer (EVEVT), so Baidu a bit, found that the basic is from a template, some functions are not complete, now summarize their own. Note: The MySQL version is supported for event starting from 5.1. If your version
Selectsubdate (Curdate (), Date_format (Curdate (), '%w ')-1)//Get current date in the Monday of the weekSelectsubdate (Curdate (), Date_format (Curdate (), '%w ')-7)//Get current date on Sunday of the weekThese two sentences are a method that MySQL
pick up time : Select Current_timestamp;output: 2016-06-16 16:12:52Select Now ();output:2016-06-16 16:12:52 Select Subdate (now (), Interval-second);output:2016-06-16 16:11:52 Take the next minute of the current time :Select Adddate (now (),
Problem Background:
Assume that the MySQL database has a vip_member (InnoDB table) member table. The structure is as follows:
When a member wants to buy a new member (only one month, three months, or six months can be
Code
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> -- Add_months (A, B) - From date a plus month B Select Add_months (sysdate, 5 ) From Dual; -- to_date (STR, Format) - time
Reprinted from: http://blog.sina.com.cn/s/blog_6d39ac7e01017sd6.html
Because the project needs to create a timer (evevt), Baidu just found that it basically comes from a template, and some functions are not complete, so I will summarize it
Numeric type functions:Absolute:ABS (x) "function" returns the absolute value of x "parameter" x, numeric Expression "return" number "example" Select ABS (+), ABS ( -100) from dual;--------------------------------------------------------------------
--Number of medical releases released in the last 30 daysSELECT substr (a.feed_publish_time,6, 5) as ' Date ', COUNT (*) as ' medical say number ' from Xm_feed a WHEREDate_sub (Curdate (), INTERVAL) --the number of medical comments released in the
Because the project needs to create a timer (EVEVT), so Baidu a bit, found that the basic is from a template, some functions are not complete, now summarize their own.Note: The MySQL version is supported for event starting from 5.1. If your version
How to limit the size of returned result sets in Oracle and MySQLIn ORACLE:
How can I use rownum to limit the number of rows returned by a query?Software environment:1. Windows NT4.0 + Oracle 8.0.42. Oracle installation path: C:/orant
Description:1.
Original works of Lin Bingwen Evankaka. For more information, see http: blogcsdnnetevankaka Lin Bingwen Evankaka. Reprinted please indicate the source http://blog.csdn.net/evankaka
MySQL database provides a wide range of functions. MySQL functions
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.