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 2000 Forums
 SQL Server Development (2000)
 Date issues in sqlserver 2000

Author  Topic 

sqldba2k6
Posting Yak Master

176 Posts

Posted - 2007-07-19 : 14:47:51
I need to convert to desired output:

declare @date1 varchar(13)
set @date1='070810104503'
select @date1

Ouput:

2007-08-10 10:45:03.000

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-07-19 : 14:49:42
You will prbly have to do concatenation using substring.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

sqldba2k6
Posting Yak Master

176 Posts

Posted - 2007-07-19 : 15:04:26
I tried with the below query the output is not showing correctly...

declare @date1 varchar(13)
set @date1='070810104503'
select Convert(DateTime, Stuff(Stuff(Stuff(Stuff(Stuff( @date1, 11, 0, ':'), 9, 0, ':'), 7, 0, ' '), 5, 0, '-'), 3, 0, '-'))


Output with the above query:
2010-07-08 10:45:03.000

Expected output should be
2007-08-10 10:45:03.000



Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2007-07-19 : 15:15:01
[code]
declare @date1 varchar(13)
set @date1='070810104503'
select DT=convert(datetime,'20'+Stuff(Stuff(Stuff(@date1,11,0,':'),9,0,':'),7,0,' '))

Results:
DT
------------------------------------------------------
2007-08-10 10:45:03.000

(1 row(s) affected)



[/code]

CODO ERGO SUM
Go to Top of Page

sqldba2k6
Posting Yak Master

176 Posts

Posted - 2007-07-19 : 19:03:41
Thanks!!
Go to Top of Page
   

- Advertisement -