gh9
gh9

Reputation: 10703

SQl SET DATEFIRST when using DATENAME

When the date parameter has a date data type argument, the return value depends on the setting specified by using SET DATEFIRST. From DateName MSDN page

If I am trying

DateName(dw,getdate()) = 'sunday'

do I need to worry about setting the DATEFIRST? I don't think I have to because I am not using the integer return, I am checking the Name of the day of the week that it was. Is this correct?

Upvotes: 2

Views: 270

Answers (1)

Damien_The_Unbeliever
Damien_The_Unbeliever

Reputation: 239684

The unasked question I think is - what's a reliable way to find a sunday.

I usually compare with a known good date of the right type:

IF DATEPART(dw,getdate()) = DATEPART(dw,'20130203')

Upvotes: 2

Related Questions