How to get a date in YYYY-MM-DD format from a TSQL datetime field?

问题:

How do I retrieve a date from SQL Server in YYYY-MM-DD format?如何以YYYY-MM-DD格式从 SQL Server 检索日期? I need this to work with SQL Server 2000 and up.我需要它与 SQL Server 2000 及更高版本一起使用。 Is there a simple way to perform this in SQL Server or would it be easier to convert it programmatically after I retrieve the result set?是否有一种简单的方法可以在 SQL Server 中执行此操作,或者在检索结果集后以编程方式转换它是否更容易?

I've read the CAST and CONVERT on Microsoft Technet, but the format I want isn't listed and changing the date format isn't an option.我已阅读 Microsoft Technet 上的CAST 和 CONVERT ,但未列出我想要的格式,并且无法更改日期格式。


解决方案:

参考一: https://en.stackoom.com/question/3jQr
参考二: https://stackoom.com/question/3jQr
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章