AllInWorld99 provides a reference manual covering many aspects of web programming, including technologies such as HTML, XHTML, CSS, XML, JavaScript, PHP, ASP, SQL,FLASH, jQuery, java, for loop, switch case, if, if else, for...of, for...in, for...each,while loop, blogger tips, blogger meta tag generator, blogger tricks, blogger pagination, client side script, html code editor, javascript editor with instant output, css editor, online html editor, materialize css tutorial, materialize css dropdown list,break, continue statement, label,array, json, get day and month dropdown list using c# code, CSS button,protect cd or pendrive from virus, cordova, android example, html and css to make android app, html code play,telerik show hide column, Transparent image convertor, copy to clipboard using javascript without using any swf file, simple animation using css, SQL etc. AllInWorld99 presents thousands of code examples (accompanied with source code) which can be copied/downloaded independantly. By using the online editor provided,readers can edit the examples and execute the code experimentally.


Get Day Name / DATENAME in SQL

     DateName is mainly used to get the Name of the date for the given Date like (Sunday, Monday,...), also this is used to following purpose.

1. Get the Day Name
2. Get the Month Name
3. Get the Week of the year
4. Get the Quarter of the Year
5. Get the Day of the Year

1) Get the Day Name
     This is used to get the day name from the given date (Sunday, Monday, Tuesday,...).

Example
SELECT DATENAME(DW,'01/7/2013') as DayName

Output
DW in SQL








2) Get the Month Name
     This is used to get the Name of the month from the given date (January, February, March, April, May,... )

Example
SELECT DATENAME(MONTH,'01/7/2013') as MonthName

Output
Datename in month







3) Get the Week of the year
     Find the number of the week in the given year.

Example
SELECT DATENAME(WEEK,'01/7/2013') as WeekOfYear

Output
Datename in Week







4) Get the Quarter of the Year
     Find number of the quarter from the given year.

Example
SELECT DATENAME(QQ,'04/7/2013') as Quarter

Output
QQ in datename







5) Get the Day of the Year
     Count and display the number of the day from the given date.

Example
SELECT DATENAME(DY,'1/20/2013') as DayOfYear

Output
DY in Datename










0 comments:

Post a Comment

Total Pageviews