Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Failure to convert datetime from character Error Post Reply Post New Topic
Author Message
petronas
Newbie
Newbie


Joined: 10 Nov 2008
Online Status: Offline
Posts: 6
Quote petronas Replybullet Topic: Failure to convert datetime from character Error
    Posted: 17 Nov 2008 at 11:30am

Hi,

I have the below SQL query in Creports. It is throwing an error " Conversion failed when converting datetime from character string".

Declare @Get_Date datetime, @StartDate Varchar(30)

select  @StartDate  = '{?StartDate}'

Select @Get_Date = convert(varchar ,month(Getdate()) )+ '/01/' +convert(varchar, year(Getdate()))
Select @Get_Date = dateadd(m,datediff(m,0, convert(datetime,@StartDate) ),0)

I think I am missing something. Any ideas?

Thanks,
Petronas

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 18 Nov 2008 at 6:26am
Where are you doing this? And the first @Get_Date isn't used...And the 2nd @Get_Date seems to be getting the starting date of the month from 0. 
But what might be the cause is the first @Get_Date, it is a string...add a CONVERT(DATETIME, (convert(varchar....
 
That should get you around the error, I think
 
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.