且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在SQL中将varchar转换为日期和顺序?

更新时间:2022-12-10 07:51:39

P!{LoggedInUserAttribute_ClientID}
aname = ' Micro DPC'
SUBSTRING(条形码, 7 3 IN ' JAN',' FEB'' APR'' MAY'' JUN'' JUL'' AUG'
' SEP'' OCT'' NOV'' DEC'
order by right convert datetime ' 15' + ' 条形码' 6 ), 5
P!{LoggedInUserAttribute_ClientID} and aname = 'Micro DPC' and SUBSTRING(barcode,7,3) IN ('JAN','FEB','APR','MAY','JUN','JUL','AUG', 'SEP','OCT','NOV','DEC') order by right(convert(datetime,'15' + 'barcode', 6),5)


更改

Change
right(convert(datetime,'15' +  'barcode', 6),5)






to

convert(datetime,'15' + right( 'barcode', 5),6)





这适用于SQL Server 2008



This is working in SQL Server 2008