SQL Server gets the current date in the specified format

Source: Internet
Author: User
Tags getdate

Using GETDATE () in the SQL Server date function to get the current date, the following will show you how to get the date using the SQL Server date function.

But what if we just need to get the current date, do not need the time part, or do not need the date as long as the time part, or I want as long as the date in the field appears in some form, what should I do?

You can use the CONVERT (varchar), GETDATE (), 120) method to implement, where varchar (10) Defines the length of the field you want, of course, the length of the different return will not, if we just date part, set to 10 is exactly the date length , if set to 19, you can read the time section exactly.

Now we introduce the parameters of the last generation, respectively, the parameters of the generation and the results of the examples are explained:

SQL Server gets the current date in the specified format

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.