Original address: http://database.51cto.com/art/200905/124240.htmSameShowThe timestamp column is displayed in the same format as the datetime column. In other words, the display width is fixed at 19 characters, and the format is Yyyy-mm-dd HH:MM:SS.DifferentRangedatetime Retrieves and displays datetime values in the ' yyyy-mm-dd HH:MM:SS ' format. The supported range is ' 1000-01-01 00:00:00 ' to ' 9999-12-31 23:59:59 '
Things
From_unixtime/unix_timestamp overflow, unable to use
Cause
From_unixtime returns the number of seconds from 1970-01-01 to the present, which is the result of the int, and the valid range of int is [ -2^31 + 1, 2^31-1], i.e. [-2147483648, 2147483648], 2147483648 /365/24/3600 conversion Adult also for more than 68 years, the maximum validity is one day in 2038.
Processing
Compatibility with previous processing, can be used first, then minus 30, you can temporarily scal
MySQL transition timestamp, directly let the MySQL statement display time or time stamp form.
Convert Time to Timestamp
The code is as follows
Copy Code
Select Unix_timestamp (' 2014-1-1 00:00:00′)
If the parameter is empty, it is processed as the current time, showing the curren
Turn from:automatic generation and update of timestamp in MySQLThe timestamp type in MySQL can set default values, just like any other type.1, Automatic Update and insert to the current time:Table:---------------------------------Table Create Table------ --------------------------CREATE TABLE ' T1 ' ( Data:1 2007-10-08 11:53:352 2007-10-08 11:54:00INSERT into
Use the datetime type to store the time in the MySQL database, use Resultset.gettimestamp () When reading this field in JDBC, and get a java.sql.Timestamp type of data. Neither resultset.getdate () nor resultset.gettime () can be used here, as the former does not include the time data, which does not include the date data.However, it is not completely secure when using Resultset.gettimestamp (), for example, when a field value of type
MySQL modifies the Database Engine
Replace the database engine in MySQL using: alter table mytable engine = InnoDB
MySQL foreign key Type Error
Code 1005, SQL status hy000: can't create table '. /grasspubsys/# sql-5bc_3.frm '(errno: 150) This error is generally caused by a problem with the foreign key, MySQL offic
Tags: and time Retrieve SQL database pos type automatic datatime readabilityDatetimeUsed when you need a value that contains both date and time information. MySQL retrieves and displays the datetime value in ' yyyy-mm-dd HH:MM:SS ' format, supported by ' 1000-01-01 00:00:00 ' to ' 9999-12-31 23:59:59 '. 8 bytes of storage.DATEWhen you need only a date value, there is no time part. MySQL retrieves and displa
from_unixtime formatting MySQL timestamp functionMySQL did not carry out in-depth research, lack of basic knowledge, a problem can only be manuals, it seems to be the MySQL learning schedule. Function: From_unixtimeEffect: Displays the time in MySQL as an int (11) in the "YYYY-MM-DD" format.Syntax: From_unixtime (Unix_
The formula for using EXECL to convert timestamps is:
Code:= (xxxxxxxxxx+8*3600)/86400+70*365+19
Use the MySQL tutorial statement to explain timestamp syntax examples:
Code:
Select From_unixtime (1234567890, '%y-%m-%d%h:%i:%s ')
Report:In MySQL, the storage type of a time field is int (11), how to convert to a character type, for example, storage is 13270655
Label:MySQL provides two functions: From_unixtime (time_stamp), convert timestamp to date
unix_timestamp (date) converts the specified date or date string to a timestamp If you want to check the records of orders for the day:[Plain]
Select Count(*) fromB_orderWhereDate_format (From_unixtime (Create_time),'%y-%m-%d')=Date_format (now (),'%y-%m-%d') can also be:[Plain]
Select Count(*) fromB_ord
Mysql timestamp is converted into two common readable time formats. For more information, see.
Mysql timestamp is converted into two common readable time formats. For more information, see.
The formula is:Code:
Syntax example:
Code:
Appendix:In mysql, the storage type o
MySQL timestamp type and time zone
MySQL's timestamp type time range between ' 1970-01-01 00:00:01 ' and ' 2038-01-19 03:14:07 ', exceeding this range the value is recorded as ' 0000-00-00 00:00:00 ', an important feature of this type is that the time that is saved is closely related to the timezone, which is the UTC (Universal Time coordinated) standard, which
This feature is required for projects. When I use navicat to set the date type to timestamp, I will find that IDE has one more option:
This feature is required for projects. When I use navicat to set the date type to timestamp, I will find that IDE has one more option:
This feature is required for projects.
When I use navicat to set the date type to timestamp
One of the problems that you encounter when you deploy your program, the MySQL definition is as follows:
Copy Code code as follows:
CREATE TABLE ' Example ' (
' ID ' INTEGER UNSIGNED not NULL auto_increment,
' Created ' TIMESTAMP not NULL DEFAULT Current_timestamp,
' LastUpdated ' TIMESTAMP not NULL on UPDATE Current_timestamp,
PRIMARY KEY
Create Table 'ts '(
'Ts1' timestamp not null,
'Ts2' timestamp not null default current_timestamp,
'Ts3' timestamp null default null
) Engine = InnoDB default charset = utf8
Error code: 1293Incorrect table definition; there can be only one timestamp column with current_timestamp in default or on update clause
Execution
MySQL has a field reg_addtime is the time value stored in the timestamp mode.
May I ask how to inquire, for example, May 1, 2013, to May 10, 2013, registered membership list it.
My side dish, a bottle discontent, half bottle wandering. Show me the hero.
Reply to discussion (solution)
SELECT * from Tbl_name WHERE from_unixtime (reg_addtime, '%y-%m-%d ') between ' 2013-05-01 ' and ' 2013-05-10 '
Yo
=utf8 comment= ' second kill inventory table ';
The reason is that when you set the timestamp to on Updatecurrent_timestamp, the other timestamp fields need to explicitly set the default valueBut if you have two timestamp fields, but only the first one is set to Current_timestamp and the second does not have a default value,
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.