MySQL Time function conversion

Source: Internet
Author: User
Tags local time

1 now ()//Current Time 2 sysdate ()//Current time 3 Current_timestamp 4 returns the current date and time in ' Yyyy-mm-dd HH:MM:SS ' or YYYYMMDDHHMMSS format, Depends on whether the function is used in a string or in the context of a number. 5 mysql> Select Now (); 6 ' 1997-12-15 23:50:26 ' 7 mysql> Select now () + 0; 8-19971215235026

1 Unix_timestamp (date) 2 returns a UNIX timestamp (the number of seconds from ' 1970-01-01 00:00:00 ' GMT) if no argument is called. If Unix_timestamp () is called with a date parameter, it returns the value of the second starting at ' 1970-01-01 00:00:00 ' GMT. Date can be a date string, a DateTime string, a timestamp, or a number in the local time in YYMMDD or YYYYMMDD format. 3 mysql> Select Unix_timestamp (), 4-8822263575 mysql> Select Unix_timestamp (' 1997-10-04 22:23:00 '); 6-8759965807 When Unix_timestamp is used for a timestamp column, the function will accept the value directly, without the implied "String-to-unix-timestamp" transform.

1 From_unixtime (Unix_timestamp) 2 returns the value represented by the YYYYMMDDHHMMSS parameter in the ' Yyyy-mm-dd HH:MM:SS ' or unix_timestamp format. Depends on whether the function is used in a string or in a numeric context. 3 mysql> Select From_unixtime (875996580), 4, ' 1997-10-04 22:23:00 ' 5 mysql> Select From_unixtime (875996580) + 0; 6-19971004222300

1 From_unixtime (Unix_timestamp,format) 2 Returns a String representing the Unix time token, formatted according to the format string. FORMAT can contain the same modifiers as the entries listed in the Date_format () function. 3 mysql> Select From_unixtime (Unix_timestamp (), 4 '%Y%d%M%h:%i:%s%x '), 5, ' 1997 23rd December 03:43:30 X '

1 sec_to_time (seconds) 2 returns the seconds parameter, changing to hours, minutes, and seconds, with values formatted as ' HH:MM:SS ' or HHMMSS, depending on whether the function is used in a string or in a numeric context. 3 mysql> Select Sec_to_time (2378); 4, ' 00:39:38 ' 5 mysql> Select Sec_to_time (2378) + 0;6-3938

Time_to_sec (time) returns the time parameter, converted to seconds. Mysql> Select Time_to_sec (' 22:23:00 ');-> 80580mysql> Select Time_to_sec (' 00:39:38 ');-> 2378

This article page can be http://www.cnblogs.com/zeroone/archive/2010/05/05/1727659.html


Select COUNT (*) from ' Tbl_app ' WHERE ' Create_time ' >unix_timestamp (now ()) -24*60*60

MySQL Time function conversion

Related Article

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.