How do you convert the number you get from datepart to the name of the day?

回眸只為那壹抹淺笑 提交于 2019-12-05 04:43:02
select datename(weekday, getdate());

It actually took me more searching than I thought it would to find this answer. It's funny how you can use a technology for ages and never know about simple functions like this.

select datename(dw,  getdate())

I'm not sure how localization would work with this function. Getting the name client-side is probably the answer, but it would be nice to do it on the database. Would Sql Server use the collation setting to determine the output for this?

This is not possible without using the result to select the day yourself. For one thing the textual representation of the day is locale-dependent. For another the returned value depends upon the 'datefirst' setting.

If you want a localizable solution, just join the result against a table with the names and numbers.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!