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(dw, GETDATE())

Reference : Pinal Dave (https://blog.sqlauthority.com)

Solarwinds
, ,
Previous Post
SQL SERVER – Create Default Constraint Over Table Column
Next Post
SQL SERVER – Order Of Column In Index

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

Menu