问题
I am interested in converting a date value to CYYMMDD
using native SQL Server 2012 functions.
I checked here:
http://www.sql-server-helper.com/tips/date-formats.aspx
and couldn't find anything.
Anyone know?
C stands for century I guess...
回答1:
Have you looked at the new FORMAT
function in SQL Server 2012?
http://msdn.microsoft.com/en-us/library/hh213505.aspx
You should be able to use something like this:
SELECT FORMAT(YourDateColumn, 'yyyyMMdd')
or whatever you really want to use - basically, the same formatting options as in C# / .NET are available when using FORMAT
来源:https://stackoverflow.com/questions/24292797/convert-date-to-cyymmdd-sql-server