SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL DATE convert
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

gooogle
Starting Member

USA
2 Posts

Posted - 08/16/2012 :  15:49:02  Show Profile  Reply with Quote
I have this SQL below:

.....
where UpdateDateTime > (select CAST ('#p_MaxDate#' as DATETIME))

The value for p_MaxDate that I am getting as parameter is:
p_MaxDate = "2012-08-14 14:15:41"

But I am getting this error:
[Microsoft][ODBC SQL Server Driver][SQL Server]Conversion failed when converting date and/or time from character string.

I also tried

where UpdateDateTime >(select CONVERT(DATETIME, ('#p_MaxDate#', 111)) & tried
where UpdateDateTime >(select CAST ('#p_MaxDate#' as DATETIME))

Still same error ...

Any ideas anyone?

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 08/16/2012 :  16:00:44  Show Profile  Reply with Quote
where are you using this code?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

webfred
Flowing Fount of Yak Knowledge

Germany
8513 Posts

Posted - 08/16/2012 :  16:01:23  Show Profile  Visit webfred's Homepage  Reply with Quote
all between single quotes is a string and the string #p_Maxdate# can't be converted to a date.

what is the real column name? is it p_MaxDate or is it #p_Maxdate# or ...?


Too old to Rock'n'Roll too young to die.
Go to Top of Page

gooogle
Starting Member

USA
2 Posts

Posted - 08/16/2012 :  16:58:26  Show Profile  Reply with Quote
I am using this inside DataStage SQL stage.

The column name on the table is UpdateDateTime & (p_MaxDate) is the parameter which is being passed in the WHERE clause.

The parameter is being passed as a string & I think I need to convert this from string to datetime or timestamp.

Edited by - gooogle on 08/16/2012 16:59:50
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000