Skip to content

Store procedure date conversion error.

Rajesh Kumar

Rajesh Kumar

Asked Sep 17, 2014, 2:34 AM EDT2 answers
Share
LinkedInX
Hi,
I have a store procedure that giving some error in running.
error"Conversion failed when converting date and/or time from character string"
USE [db]
GO
/****** Object: StoredProcedure [db].[Select_Top5] Script Date: 09/17/2014 15:24:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [db].[Select_Top5]
as
begin
select top 5 RANK() OVER (ORDER BY convert(int, Round(( Cast( DATEDIFF(YY,convert(datetime,Playerdob,101),( select convert(datetime,getdate(),101) ) )*bowlingpoint as Float)/32),0)) desc) AS Rank,PlayerId,PlayerName, Round(( Cast( DATEDIFF(YY,convert(datetime,Playerdob,101),( select convert(datetime,getdate(),101) ) )*bowlingpoint as Float)/32),0) as bowlingpoint ,Totalmatches, t.TeamName as Team,t.TeamId as TeamId from Playerprofile join TeamProfile t on Playerprofile.TeamId=t.TeamId
end
Can anyone able to solve this problem.
Thanks

2 Answers

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    hi, would you please paste data from tables for some clarity. thnx
    0
  • Rajesh Kumar
    0
    Which data you want here
    playerdob i stored in database as 1-jan-1987.
    0