Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
srinivas.alwala
Starting Member
30 Posts |
Posted - 2008-04-23 : 06:33:08
|
Hi,Data imports from Excel to sql tables thru DTS Package.The Date Value in Excel column is as : 200802.0Now,I need to convert the above date to as 01 Feb 2008select convert(varchar(11),convert(varchar(12),'01-' + convert(varchar(2),right(left(dtcol,6),2)) + '-' + left(dtcol,4),121))from tblnameThe above query giving an output as 01-02-2008Pls let me know how the above date can modified to 01 Feb 2008Regards,Srinivas Alwala |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-04-23 : 07:13:49
|
[code]DECLARE @dtCol NUMERIC(8, 1)SET @dtCol = 200802.0-- With variableSELECT CONVERT(CHAR(11), CAST(STR(@dtCol, 6, 0) + '01' AS DATETIME), 106)-- With table and columnSELECT CONVERT(CHAR(11), CAST(STR(dtCol, 6, 0) + '01' AS DATETIME), 106)FROM tblName[/code] E 12°55'05.25"N 56°04'39.16" |
 |
|
|
|
|
|
|