Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Failure to convert datetime from character error

Status
Not open for further replies.

PPetronas

Programmer
Nov 13, 2008
14
0
0
US
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
 
It's not clear what you're after: also there is a separate SQL forum and it would be better to ask there for something that's purely about SQL.

Still, since you have posted, this is something I wrote in SQL that worked OK and may be useful:
Code:
Set @ArMax01= '10-' + Convert(Char(2), DatePart(Month, @LastMonth)) + '-' + Convert(Char(4), DatePart(Year, @LastMonth))


[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top