Search - Articles
DevASP.NET for ASP.NET, VB.NET, XML and C# (C-Sharp) Developers Tuesday, March 03, 2009
Dev Articles
Search Directory
ASP.NET
VB.Net
C-Sharp
SQL Server
 

Working with Datepart() function in SQL Server 2008 using PL/SQL.

Author: Shehzad Hemani

In this simple article you will learn that how to work with Datepart() function in SQL Server using PL/SQL.

 Datepart() is the one of the most commonly used functions of SQL Server. It is used to show the specific part of the date.

 

This function takes two parameters; one is the date part to specify which part of the date is required and the other is the whole date from which the part has to be selected.

 

Syntax:

DATEPART(datepart, date)

 

It can be used only with the SELECT command. The syntax for using it with SELECT command is:

 

SELECT

DATEPART(datepart, date)

AS

Header of Column

 

Example:

To select the year from any variable DATE:

 

SELECT

DATEPART (year, DATE)

AS

YEAR

 

Output will be shown like this:

Year

-----------

2009

   
Add Article Comment:
Name :
Email Address :
   
Comments :
 
   
<< Working with DATEDIFF () function in SQL Server 2008 using PL/SQL.

Disclaimer - Privacy
© 2002-2017 DevASP.net