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.

 All Forums
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 Date format Problem

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.0
Now,

I need to convert the above date to as 01 Feb 2008

select convert(varchar(11),convert(varchar(12),'01-' + convert(varchar(2),right(left(dtcol,6),2)) + '-' + left(dtcol,4),121))
from tblname

The above query giving an output as 01-02-2008

Pls let me know how the above date can modified to 01 Feb 2008

Regards,

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 variable
SELECT CONVERT(CHAR(11), CAST(STR(@dtCol, 6, 0) + '01' AS DATETIME), 106)

-- With table and column
SELECT 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"
Go to Top of Page
   

- Advertisement -