Good day.
In a PHP script, I make a request to the SQL server with filtering by date:
$start_date = 2011-09-20 00:00:00.000 $now_date = 2011-09-20 17:45:16.999 AND moment >= CAST('$start_date' AS datetime2) AND moment <= CAST('$now_date' AS datetime2)
But the server does not recognize the conversion of the string to the date: Type date is not a defined system type.
If a
AND moment >= CONVERT (datetime, '2011-09-20 00:00:00.000', 21) AND moment >= CONVERT (datetime, '2011-09-20 18:10:02.000', 21)
In return, I get nothing, i.e. filtering conditions are not met. Tried to use CONVERT (datetime, '2011-09-20 18: 10: 02.000', 21) again, the void in response.
Does not work on SQL Server 2005 Express.
How to translate a string to a date on the 2005th. In 2008, all the above examples work.