简体   繁体   English

如何将日期转换为文本月份?

[英]How to convert date to text Month?

How do I convert the date to a month spelled out? 如何将日期转换成一个月的拼写?

For example. 例如。

01/08/2015 = January 01/08/2015 =一月

I have it code in excel =TEXT(value, "MMMM") but we are shifting away from Excel to SQL Server. 我在excel =TEXT(value, "MMMM")编写了代码,但我们正从Excel转移到SQL Server。

Thanks 谢谢

You need to use the DATENAME function. 您需要使用DATENAME函数。

For example: 例如:

SELECT DATENAME(mm, DateCol) AS [Month]
FROM MyTable
SELECT DATENAME(MONTH, GETDATE())

This is one way: 这是一种方法:

SELECT DATENAME(month, youDateField)) as Month
FROM YourTable
select datename(month,convert(varchar,yourField,106)) as month
from yourTable

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM