1.1 Get the current date + time (date + times) function: Now ()In addition to the now () function to get the current datetime, MySQL has the following function:Current_timestamp () Current_timestampLocalTime () localtimeLocaltimestamp ()
The general design of flow-type SQL in calcite flow sqlcalciteThe overall syntax should be compatible with SQL, which is consistent with the current trend of stream processing SQL.If some of the features are not included in standard SQL, try to use
Here is an example of using the date function. The following query Selects all records whose date_col values are within the last 30 days.
Here is an example of using the date function. The following query Selects all records whose date_col values
To create a table:
Copy Code code as follows:
CREATE table if not exists t
(
ID int,
Addtime datetime default ' 0000-00-00 00:00:00′
)
Add two initial data:
Insert T VALUES (1, ' 2012-07-12 21:00:00′);Insert T
Date_add (date, INTERVAL expr type) date_sub (date, INTERVAL expr type )
These functions perform date operations. Date is a DATETIME or date value that specifies the starting time. expr is an expression that specifies the value of a time
Here is an example of using a date function. The following query selects records for all Date_col values within the last 30 days.Mysql> SELECT something from Tbl_nameWHERE To_days (now ()) –to_days (date_col) DAYOFWEEK (date)Returns the week index
description of MySQL data_add function and date format function
Date_add (date, INTERVAL expr type) date_sub (date, INTERVAL expr type )
These functions perform date operations. Date is a DATETIME or date value used to specify the
Mysql data from the previous month, January, a week ago, mainly used DATE_SUB,
Refer to the following
Copy codeThe Code is as follows:SELECT * FROM yh_contentWhere inputtime> DATE_SUB (CURDATE (), INTERVAL 1 DAY)Where inputtime> DATE_SUB (CURDATE (),
Mysql> SELECT something from Tbl_name
WHERE To_days (now ()) –to_days (date_col)
DayOfWeek (date)
Returns the week index of date (1 = Sunday, 2 = Monday, ...). 7 = Saturday). Index values are compliant with ODBC standards.
mysql> SELECT DayOfWeek ('
The following query selects the records for all date_col values within the last 30 days.
Mysql> SELECT something from Tbl_name
WHERE To_days (now ())-To_days (Date_col) DayOfWeek (date)
Returns the week index of date (1 = Sunday, 2 = Monday, ...). 7
MySQL data from a year ago a week ago yesterday the main use of date_sub,
Refer to the following
Copy Code code as follows:
SELECT * from Yh_content
where Inputtime>date_sub (Curdate (), INTERVAL 1 day)
where Inputtime>date_sub
MySQL queries a lot of ways, the following for you to introduce the MySQL query is to query this week, last week, this month, the last month's data, if you are interested in MySQL query, may wish to see.Query the current data todaySELECT
MySQL time to get a timely conversion between1.1 Get the current date + time (date + times) function: Now ()In addition to the now () function to get the current datetime, MySQL has the following function:Current_timestamp ()
1.0 Formatting: The Date_format () function is used to display date/time data in different formats.GrammarDate_format (Date,format) The date parameter is a valid day. format Specifies the date/time in which the output is formatted.The formats you
Transfer from http://blog.sina.com.cn/s/blog_6d39dc6f0100m7eo.html1.1 Get the current date + time (date + times) function: Now ()In addition to the now () function to get the current datetime, MySQL has the following function:Current_timestamp ()
This content is transferred from a Sina blog article later I will optimize the content Http://blog.sina.com.cn/s/blog_6d39dc6f0100m7eo.html In addition to the now () function to get the current datetime, MySQL has the following function:
MySQL yesterday a week ago a year ago the data here mainly used in the date_sub,Refer to the followingThe code is as follows:SELECT * from Yh_contentwhere Inputtime>date_sub (Curdate (), INTERVAL 1 day)where Inputtime>date_sub (Curdate (), INTERVAL 1
Reference: http://blog.sina.com.cn/s/blog_6d39dc6f0100m7eo.htmlLocaltimestamp () LocaltimestampThese date-time functions are equivalent to now (). Since the now () function is short and easy to remember, it is recommended that you always use now ()
PostgreSQL tutorial (6): Functions and operators (2), postgresql Operators
6. Pattern Matching:
PostgreSQL provides three methods for implementing pattern matching: SQL LIKE operator, closer SIMILAR TO operator, and POSIX-style regular expression.1.
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.