Time and date types of mysql + mssql + oracle

Source: Internet
Author: User
1: sqlserver DATE type: For YYYY-MM-DDHH: MM: SS2.mysql DATE and Time type: DATE, DATE. The supported range is 1000-01-01 to 9999-12-31. MySQL displays a combination of DATEDATETIME, date, and time in YYYY-MM-DD. Supported range: 1000-01-0100:00:00 to 9999

1: SQL server DATE type: For 'yyyy-MM-DD HH: MM: SS 2. mysql DATE and Time type: DATE, DATE. The supported range is '2017-01-01 'to '2017-12-31 '. MySQL displays a combination of date datetime, DATE, and time in 'yyyy-MM-DD 'format. The supported range is '2017-01-01 00:00:00 'to '2017

1: SQL server date type:

For 'yyyy-MM-DD HH: MM: SS

2. mysql Date and Time type:
DATE. The supported range is '2017-01-01 'to '2017-12-31 '. MySQL displays the DATE value in 'yyyy-MM-DD 'format
DATETIME, a combination of date and time. The supported range is '2017-01-01 00:00:00 'to '2017-12-31 23:59:59 '. MySQL displays DATETIME values in 'yyyy-MM-DD HH: MM: ss' format
TIMESTAMP [(M)], Timestamp. Returns a string in 'yyyy-MM-DD HH: MM: ss' format with a fixed display width of 19 characters.
TIME, TIME. The value range is '-838: 59: 59' to '2014: 59: 59 '. MySQL displays the TIME value in the format of 'hh: MM: ss '.
YEAR [(2 | 4)], two or four-digit YEAR. The default format is four bits. In the four-digit format, the allowed values are 1901 to 2155 and 0000. In the two-digit format, the allowed values are 70 to 69, indicating that the value ranges from January 1, 1970 to January 1, 2069. MySQL displays the YEAR Value in YYYY format

3:The default date and time format of JAVA is

Thu Jul 07 17:05:39 CST 2005

To convert the format to, use the SimpleDateFormat class.

SimpleDateFormat formatt = new SimpleDateFormat ("yyyy-MM-dd ");
Date date = new Date ();
System. out. println (formatt. format (date ));

The printed format is:

SimpleDateFormat formatt = new SimpleDateFormat ("yyyy-MMMM-dd ");
Date date = new Date ();
System. out. println (formatt. format (date ));

The printed format is: 2005-July-07

---------------------------

4: default date format of Oracle

SQL> select sysdate from dual;

SYSDATE
----------
Month 7-05

Convert to_char to yyyy-mm-dd format

SQL> select to_char (sysdate, 'yyyy-mm-dd') Time from dual;
TIME
----------
2005-07-07

There are two date-related functions in Oracle: to_date () and to_char ();

To_date () converts the character type to the date type in a certain format:
Specific usage: to_date ('1970-11-27 ', 'yyyy-mm-dd'). The former is a string, and the latter is a conversion date format. Note that the first and second data must be in the correct format.
For example, to_date ('2017-11-27 13:34:43 ', 'yyyy-mm-dd hh24: mi: ss') will get the specific time
To_date () converts the character type to the date type in a certain format:
Specific usage: to_date ('1970-11-27 ', 'yyyy-mm-dd'). The former is a string, and the latter is a conversion date format. Note that the first and second data must be in the correct format.
For example, to_date ('2017-11-27 13:34:43 ', 'yyyy-mm-dd hh24: mi: ss') will get the specific time.


Source: Small Partner Development Network http://www.kaifaer.com/

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.