Obtain system time by SQL

Source: Internet
Author: User
1. Select getdate ()
Lili to the current time

2. Select convert (char, getdate (), 010) can get the current date.
The last parameter is used to determine the date format. The following is the format table.
Format: 000 output Date Format: SEP 14 200
Format type: 001 output Date Format: 09/14/01
Format type: 002 output Date Format: 01.09.14
Format type: 003 output Date Format: 14/09/01
Format type: 004 output Date Format: 14.09.01
Format type: 005 output Date Format: 14-09-01
Format type: 006 output Date Format: 14 Sep 01
Format type: 007 output Date Format: SEP 14, 01
Format type: 008 output Date Format: 17:06:08
Format type: 200 output Date Format: SEP 14
Format type: 010 output Date Format: 09-14-01
Format type: 011 output Date Format: 01/09/14
Format type: 012 output Date Format: 010914
Format: 013 output Date Format: 14 Sep 200
Format: 014 output Date Format: 17: 06: 08: 7
Format: 015 output Date Format: 17: 06: 08: 7
Format: 016 output Date Format: 17: 06: 08: 7
Format type: 017 output Date Format: 17: 06: 08: 7
Format: 018 output Date Format: 17: 06: 08: 7
Format: 019 output Date Format: 17: 06: 08: 7
Format: 020 output Date Format: 2001-09-14
Format type: 021 output Date Format: 2001-09-14
Format type: 022 output Date Format: 09/14/01
Format: 023 output Date Format: 2001-09-14
Format type: 024 output Date Format: 17:06:08

3. Select datediff (hour, '2017-12-8 21:41:42 ', getdate ())
Obtains the difference between the current time and the specified time.

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.