Hello,

I am having trouble getting data from a DATETIME field in MSSQL 7.0.

The data in a general select query look like this:

2001-09-25 14:23:17.000


I can do this in MSSQL:

select * from INTERNETLOG where Datetime like %2001%

but not this:

select * from INTERNETLOG where Datetime like %2001/09/25%
or
select * from INTERNETLOG where Datetime like %20010925%
or
select * from INTERNETLOG where Datetime like %2001/09%
or
select * from INTERNETLOG where Datetime like %14:23%

I think it has to do with converting the data type but that's where I'm
stuck.

from the SQL manual:

Pattern Matching with LIKE
It is recommended that LIKE be used when you search for datetime values,
because datetime entries can contain a variety of dateparts. For example, if
you insert the value 19981231 9:20 into a column named arrival_time, the
clause WHERE arrival_time = 9:20 cannot find an exact match for the 9:20
string because SQL Server converts it to Jan 1, 1900 9:20AM. However, the
clause WHERE arrival_time LIKE %9:20% does find it.

I've seen a couple of initial questions asked about the same problem but not
the answer. Is this a PHP/ODBC issue or just MSSQL?

-m


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to