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!

SELECT DATENAME(dwGETDATE())

Reference : Pinal Dave (http://blog.SQLAuthority.com)

6 thoughts on “SQL SERVER – SQL SERVER – UDF – Get the Day of the Week Function – Part 4

  1. 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.

    Like

  2. 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

    Like

  3. Pingback: SQL SERVER – Weekly Series – Memory Lane – #031 | Journey to SQL Authority with Pinal Dave

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s