Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
sql_server 217
t-sql 211
tsql 116
sqlserver 96
BRH 78
#SQLServer 66
#TSQL 56
SQL Server 34
function 11
SSMS 9

Archive · View All
August 2007 17
August 2010 8
June 2012 7
June 2011 7
November 2007 7
August 2012 6
May 2012 6
November 2011 6
August 2011 6
October 2011 6

Madhivanan's TSQL Blog

DATENAME vs DATEPART functions

Feb 7 2011 1:58AM by Madhivanan   

Both the functions DATENAME and DATEPART are used to extract the informations from the date. However there is a difference between the two in terms of return datatype. DATENAME function always return the varchar datatype whereas DATEPART functions return Integer datatype Consider the following example which is used to extract year value from current date

DATENAME returns varchar datype where DATEPART returns Integer datatype

SELECT DATENAME(year,GETDATE())
SELECT DATEPART(year,GETDATE())

Both the above returns the value 2011 Now to check the actual datatype returned, run the following

SELECT DATENAME(year,GETDATE())+'a'
SELECT DATEPART(year,GETDATE())+'a'
  

The first code returns the value 2011a

-------------------------------
2011a

whereas the second code returns the error

Msg 245, Level 16, State 1, Line 2
Conversion failed when converting the varchar value 'a' to data type int.

So it is clear that the return type of DATENAME is varchar and return type of DATEPART is Integer

Tags: tsql, BRH, SQL Server, #TSQL, #SQLServer,


Madhivanan
3 · 39% · 12440
1
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"DATENAME vs DATEPART functions" rated 5 out of 5 by 1 readers
DATENAME vs DATEPART functions , 5.0 out of 5 based on 1 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]