且构网

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

在SQL Server 2008中将特定日期格式转换为日期时间格式

更新时间:2023-01-28 22:17:25







试试这个



Hi,


Try this

ColoumnValues = "convert(datetime," + replace(ColoumnNames,'th','') + ") between convert(datetime,'" + replace(ds.Tables[0].Rows[i]["StartDuration"].ToString(),'th','') + "') and convert(datetime,'" + replace(ds.Tables[0].Rows[i]["EndDuration"].ToString(),'th','') + "')";










declare @date varchar(20)

set @date= '12-March-2013'

select @date

select CONVERT(datetime,replace(@date,'th',''),111)