• Igor Micev (1/20/2016)


    newbieuser (1/20/2016)


    Thanks got it.

    declare @weekday varchar(10)

    declare @in_date date='01/20/2016'

    select @weekday=datename(weekday,CONVERT(VARCHAR(10),@in_date,101))

    select @weekday

    Even if you don't convert it with a style, sql server will recognize it and return the day-name from the date. Just try.

    Leaving off the style, the 101, will probably work but it is best to include it as leaving it off can cause problems.

    Per your earlier link

    When the language is set to us_english, the default order for the date is mdy. You can change the date order by using the SET DATEFORMAT statement.

    The setting for SET DATEFORMAT determines how date values are interpreted. If the order does not match the setting, the values are not interpreted as dates, because they are out of range or the values are misinterpreted. For example, 12/10/08 can be interpreted as one of six dates, depending on the DATEFORMAT setting. A four-part year is interpreted as the year.

    If someone has changed the setting using the SET DATEFORMAT or the server is using a different language you could insert an incorrect date or have the insert fail because it is invalid when the day and month are swapped.