SQL SERVER – SQL SERVER – UDF – Get the Day of the Week Function Part 4

I have been asked many times when there is DATENAME function available why do I go in exercise of writing UDF For the getting the day of the week. Answer is : I just like it! Here is Day of the Week Function Part 4 with the DATENAME way.

SQL SERVER - SQL SERVER - UDF - Get the Day of the Week Function - Part 4


SELECT DATENAME(dw, GETDATE())

Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.


Discover more from SQL Authority with Pinal Dave

Subscribe to get the latest posts sent to your email.

SQL DateTime, SQL Function, SQL Scripts
Previous Post
SQL SERVER – Create Default Constraint Over Table Column
Next Post
SQL SERVER – Example of DISTINCT in Aggregate Functions

Related Posts

5 Comments. Leave new

  • Charanpreet Singh
    June 20, 2008 3:20 pm

    can i use locationization/globalisation in sqlserver queries.

    i need month name in greek,german,turkish language

    Reply
  • Hi Dave,

    How can I use the DATENAME function within SSIS2005. I am importing a csv file and want to transform a date string field in the csv record from “YYYYMMDD” to “DDmonYY” (e.g. 20080715 to 15JUL08) . My output goes into a text file.
    Any assistance is highly appreciated.

    Reply
  • How would you go about get the date for this example.

    Week Number = 4
    Week Day = 3
    Year = 2009

    Result: 01/27/2009

    Here’s the code for the date parts:
    @week = DATEPART(WEEK, @date)
    @day_number = DATEPART(WEEKDAY, @date)
    @year = DATEPART(YEAR, @date) -1

    Thanks,
    Chris

    Reply
  • Its really good site to know everythig from its one place……..Thanking U….

    Reply
  • Pls tell me the Query, how to display Day of weeK in ascending order?

    eg:
    February
    Friday
    Monday
    Thursday
    Tuesday

    This like i want to display….

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.