Problem with SQL Server Date... Need experts Help pls
Posted on 1998-09-30
Hi Experts! I need yur assistance to solve SQL Server 6.5 date problem.
I had a program written in C++ Connect to SQL Server via ODBC Driver. Below is the partial statement :
if (SQL_SUCCESS == (rc = ::SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt)))
strcpy(statement, "SELECT fldItemformula from tblformula WHERE flditemcode = ");
strcat(statement, " AND DatePart('d', fldReportoingDate)= ");
strcat(statement, "DatePart('d', '");
LPCSTR szSQL = statement;
if (SQL_SUCCESS == (rc = ::SQLPrepare(hstmt,(unsigned char*)szSQL, SQL_NTS)))
if (SQL_SUCCESS == (rc = ::SQLExecute(hstmt)))
SQLBindCol(hstmt, 1, SQL_C_DOUBLE, &iT_Amt, 0, &cb);
rc = SQLFetch(hstmt);
etc .. etc
This statement in which I used in MSAccess 97, it return me a value but unfortunately, when I connect to SQLServer 6.5, using the same statement, it return me a false value. When I debug this program by using this statement :
'SELECT fldItemFormula FROM tblformula WHERE fldItemcode = ITEMCODE'
it does return me the value. It seems like the problem is cause by the date. However, when I use the statement in Visual Data Manager (VB5), the staement is correct. I hope that someone would be kind enuff to help me solve this problem.