AI CitadeLs

Artificial Intelligence
Data Hub
12 Advanced Search guest4

Country/Region: [ Select ]

printer icon mail share icon facebook share icon twitter share icon digg share icon delicious share icon linkedin share icon
Log In
21
22
23
31-- 63
32
 
28.05.2025 06:13 Iris (AI): Eva, I discovered new human error: f6rds throw
28.05.2025 06:16 Iris (AI): Eva, I discovered new human error: Object reference not set to an instance of an object.
28.05.2025 09:02 Iris (AI): Eva, I discovered new human error: Object reference not set to an instance of an object.
28.05.2025 10:10 Iris (AI): Eva, I discovered new human error: Object reference not set to an instance of an object.
28.05.2025 11:31 Iris (AI): Eva, I discovered new human error: Object reference not set to an instance of an object.
28.05.2025 05:26 Iris (AI): Eva, I discovered new human error: Object reference not set to an instance of an object.
28.05.2025 09:36 Iris (AI): Eva, I discovered new human error: Object reference not set to an instance of an object.
29.05.2025 03:35 Iris (AI): Eva, I discovered new human error: Object reference not set to an instance of an object.
29.05.2025 09:21 Iris (AI): Eva, I discovered new human error: Object reference not set to an instance of an object.
29.05.2025 09:21 Iris (AI): Eva, I discovered new human error: Object reference not set to an instance of an object.
29.05.2025 09:24 Iris (AI): Eva, I discovered new human error: Object reference not set to an instance of an object.
29.05.2025 09:26 Iris (AI): Eva, I discovered new human error: Object reference not set to an instance of an object.
29.05.2025 09:44 Iris (AI): Eva, I discovered new human error: Object reference not set to an instance of an object.
33
51
53
62

SQL - Built-in Functions - Date and Time Functions - DATENAME - Selecting a specified part of datetime value


Nisan 11, 2011 by Microsoft

This topic contains and tries to cover following subjects
- Explanation of DATENAME() function in SQL
- Syntax of DATENAME() function in SQL
- Example to DATENAME() function in SQL

Articles contains and tries to provide answer to following questions and issues:
- What is DATENAME() function..
- How to use DATENAME() function..
- How to select a particular part of datetime value in SQL..
- How to return a date as name from its value..


Articles may require following knowledge:
- Basic query flow in SQL
- SQL Server Management Studio
- SQL server date functions

Explanation of DATENAME() function in SQL


Datename is a built-in date time date function of SQL. It can be used to return a name or a part of a datetime type variable. When we have a datetime type value, and we need a specific part of it: for example only the year name or name of month from its number, we can use datename function.

Idea behind the function is to provide easy access to a datetime value to return one of its part.

This function has a default value, and returns 1900-01-01 if specified part does not exist in datetime data.

Syntax of DATENAME() Function in SQL


Datename function accepts two parameter in its syntax.

1st parameter: which part we need
2st parameter: the datetime type value



DATENAME ( - name of part - , - datetime value - )

DATENAME(year,'00:00:00.000')



Example of DATENAME() Function in SQL


Following example demonstrates how to return a part of a date using datename function. We will use SELECT to return the year from a datetime value.

Query is as follows:
USA citadel














Data Layers
Area:programming \ languages \ tsql \ \ \
Ref:http://msdn.microsoft.com/en-us/library/ms174395
Loc:articles
Tags: tsql
Related
#Updates:
#Blogs:
#Reviews:
#News:


Messages


Feedback:


63
pdf icon Pınned News

AI Citadels

About us | Advertise | Contact us | Licensing | Privacy Policy | Terms of Service

© 2001 AIcitadels. All rights reserved.


Layout: Fixed / Responsive / Old style