Use the SQL Server date function to get the current date in the specified format

Source: Internet
Author: User
Tags date getdate

Using the GETDATE () in the SQL Server date function to get the current date, you will be presented with a method that uses the SQL Server date function to get the present date.

But what if we just need to get the current date, don't need a part of the time, or don't need a date as long as the time part, or I want the date in the field to show in some way, how should I do?

You can use the methods such as convert (varchar), GETDATE (), 120), where varchar (10) Defines the length of the field you want, and of course the length of the difference will not return, if we just date part, set to 10 exactly for the date length , if set to 19, you can read the time section exactly.

Now we introduce the parameters of the last generation, respectively, using the parameters of generation and the effect of example:

SQL Server CONVERT () function: http://www.w3school.com.cn/sql/func_convert.asp

See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/SQLServer/

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.