Mssql function DATENAMECopy codeThe Code is as follows:SyntaxDATENAME (datepart, date)ParametersDatepartIs part of the returned date. The following table lists all valid datepart parameters. The user-defined equivalent variable is invalid.DateIs an
MSSQL function Datename
Copy Code code as follows:
Grammar
Datename (datepart, date)
Parameters
DatePart
is part of the returned date. The following table lists all the valid datepart parameters. User-defined variable
SELECT DATEDIFF (year, ' 1992-11-28 ', GETDATE ())--age, where year can be replaced by day MONTHSELECT DATEPART (Month,getdate ())-Returns an integer representing the specified date portion of the specified date. such as 12SELECT datename (WEEKDAY, '
The similarities and differences between the DATENAME function and the DATEPART function in SQL functions:
Syntax: Datename ( datepart ,date ) and datepart ( datepart , date )
Description: The Datename function obtains the name, according to the
T-SQL time operations (dateadd, datediff, datepart, datename), datepartdatename
-- 1. current System Date and Time select getdate () -- 09:27:27. 277--2. the Time Operation dateadd returns the new datetime value dateadd (datepart, number, date)
Tag:sql database --1. Current system date, time select GETDATE ()--2015-01-06 09:27:27.277--2. The time operation DateAdd returns a new datetime value DATEADD (datepart, on the basis of adding a period of time to a specified date)
server|sqlserver| function SQL Server commonly used time functions---GETDATE, getutcdate, datename SQL Server commonly used time functions---GETDATE, getutcdate, Datename Author: Amoy Net Date: 2005-4-12 15:53:24 Visits: Origin: Amoy-Net--http://www.
SQL Server Date datename getdate function
GetDate () Function instance
You can call the use of the GETDATE () function in SQL Server 2005 's user customization function (udfs:user Defined functions), which is an example of the following example:
The main use of the sql2005| function Datename function is to extract the specified part of the data from the date, such as the year we want in the current date, the month, and so on. The return type is nvarchar.
The specific syntax is as follows:
The date and time functions in SQL Server are always problematic in this regard. So, I will summarize what I mainly useDatepart(Month, getdate (). This item can be set to day (now () in access. Unfortunately, the day () in SQL Server does not
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.