In this case, it has nothing to do with the SQL Server conversion.
Your problem is because of the following: You need at Date type as first argument to the date2str() function, but you have a str type. use str2date() function to convert to date before you apply it to date2str() function. Like:
Con = new Connection();
Stmt = Con.createStatement();
sqlString = "SELECT * FROM GET_EMPLOYEE_PRIMS WHERE DSEMPLID='A1' AND DATAAREAID='" + curExt() +"' "
+ " AND TRANSDATE<CAST('"+date2str(str2date("29/09/2001",123),321,2,3,2,3,4)+"' AS datetime)"
+ " AND TRANSDATE> CAST('"+date2str(str2date("29/09/2003",123),321,2,3,2,3,4)+"' AS datetime)";
R = Stmt.executeQuery(sqlString);
/holgerkp :-)
From: "Jonathan St-Louis" <[EMAIL PROTECTED]> Reply-To: [EMAIL PROTECTED] To: <[EMAIL PROTECTED]> Subject: Re: [development-axapta] datetime conversation.. Date: Mon, 29 Sep 2003 11:24:43 -0400
I don't know what is checked by the SQL Server Query Analyser but so it maybe a stupid answer but had you check your date format in SQL?? It can be because the date isn't the same type in SQL. 2001/09/29 can be read like 2001 september 1929 (or 2029) in SQL. In this case you should set the date like 29/09/2001.
Hope it'll help.
----- Original Message ----- From: "Anil Ozay" <[EMAIL PROTECTED]> To: "Development-Axapta (E-mail)" <[EMAIL PROTECTED]> Sent: Monday, September 29, 2003 10:54 AM Subject: [development-axapta] datetime conversation..
> Hi all.. I run sql code from Axapta.. My code is :
>
> Connection Con;
> Statement Stmt;
> ResultSet R;
>
> Con = new Connection();
> Stmt = Con.createStatement();
> sqlString = "SELECT * FROM GET_EMPLOYEE_PRIMS WHERE DSEMPLID='A1' AND
DATAAREAID='" + curExt() +"' "
> + " AND TRANSDATE<CAST('" +
date2str('2001/09/29',321,2,3,2,3,4) + "' AS datetime)"
> + " AND TRANSDATE> CAST('" +
date2str('2003/09/29',321,2,3,2,3,4)+ "' AS datetime)";
> R = Stmt.executeQuery(sqlString);
>
> This code runs on Sql Server Query Analyzer successfully. I try to run
from any class on Axapta, but it doesn't work!!
>
> Error info is :
>
> [Microsoft][ODBC SQL Server Driver][SQL Server]The conversion of a char
data type to a datetime data type resulted in an out-of-range datetime
value.
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
_________________________________________________________________ Få gode tilbud direkte i din mailbox http://jatak.msn.dk
Yahoo! Groups Sponsor ADVERTISEMENT
click here
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.