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 |
Rajagopalan
Starting Member
1 Post |
Posted - 2014-04-12 : 04:29:07
|
HII created one stored procedure to update the date difference in the table . in this table i have dt1,dt2,dt3... column and diff1,diff2...i wanted to find the difference between dt2 and dt1, and dt4 and dt3 and put it in separate column.when i compiled the stored procedure, it did not show any error.but when i execute, it shows the error:Conversion failed when converting datetime from character string.I dont know where i made a mistake.Can any one help on this.thanksset ANSI_NULLS ONset QUOTED_IDENTIFIER ONgoALTER procedure [dbo].[autopost1]asbegindeclare inner intdeclare @fmm varchar(4),@too varchar(4)declare @hours as intdeclare @minutes as intdeclare @seconds as intdeclare @time_interval as nvarchar(10)set @instart = 1 while @instart <= @inner begin set @fmm = 'dt'+cast(@instart-1 as varchar) set @too = 'dt'+cast(@instart as varchar) set @hours = DATEDIFF(ss, @fmm, @too) / 3600 set @minutes = (DATEDIFF(ss, @fmm, @too) - @hours*3600)/60 set @seconds = DATEDIFF(ss, @fmm, @too) - @hours*3600 - @minutes * 60set @time_interval = (cast(@hours as nvarchar) +':'+ cast(@minutes as nvarchar)+':'+ cast(@seconds as nvarchar)) set @instart = @instart + 1 end |
|
nandiniforum
Starting Member
1 Post |
Posted - 2014-04-12 : 04:33:23
|
hiihttp://logicshore.com/ |
|
|
|
|
|
|
|