in reply to question for SQL date with win32:odbc

Just a guess but shouldn't:-
$sql = "select Date_time from Main where Date_Time >= DateAdd(\"h\", - +2, '1/05/2008 05:35') ";
be:-
$sql = "select Date_time from Main where Date_Time >= DateAdd(\"h\", - +2, '1/05/2008 05:35:00') ";
or possibly:-
$sql = "select Date_time from Main where Date_Time >= DateAdd(\"h\", - +2, '01/05/2008 05:35:00') ";
Seems like it would explain the error

I'd say this is more of an MSSQL question

Lyle

Replies are listed 'Best First'.
Re^2: question for SQL date with win32:odbc
by benlaw (Scribe) on May 16, 2008 at 01:51 UTC
    Thanks for your reply, the error still obtained.

    Really I copy & paste the sql_query to other sql software is workable rather than in my script. And really sorry that I can't clarify it's my script problem or sql problem.

Re^2: question for SQL date with win32:odbc
by MidLifeXis (Monsignor) on May 16, 2008 at 17:18 UTC

    I am not familiar with MS SQL, but aren't strings supposed to be in single quotes? Check the first parameter after DateAdd(.

    $sql = "select Date_time from Main where Date_Time >= DateAdd('h', -2, + '01/05/2008 05:35:00') ";

    Just a guess. P(roba|ossi)bly wrong.

    --MidLifeXis