Monday, March 20, 2017

SQL Functions That Get Date and Time Parts


1.   DATENAME

Syntax:                                                                          Return Type:

DATENAME(datepart,date)                          nvarchar

It returns the character string that represents the specified datepart of the specified date.




2.   DATEPART

Syntax:                                                                          Return Type:

DATEPART(datepart,date)                              int

It returns the integer that represents the specified datepart of the specified date.




3.   DAY

Syntax:                                                                          Return Type:

DAY(date)                                            int

It returns the integer that represents the daypart of the specified date.




4.   MONTH

Syntax:                                                                          Return Type:

MONTH(date)                                           int

It returns the integer that represents the monthpart of the specified date.




5.   YEAR

Syntax:                                                                          Return Type:

YEAR(date)                                           int

It returns the integer that represents the year part of the specified date.




Share This
Previous Post
Next Post

TekGrabs, established in 2017, is in the business of sharing Information. It provides news, articles and photos about the different technologies, inventions in different domains. Provides information on programming and databases.

0 comments: