Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
SQL
SELECT * FROM Parking WHERE Park_Time between cast( '15/09/2014 01:27:09 ص' AS DATETIME2) AND cast('15/09/2014 02:28:09 ص' AS DATETIME2)


when execute it show me error message

Conversion failed when converting date and/or time from character string.

what can i do ??????????
Posted
Comments
Sergey Alexandrovich Kryukov 14-Sep-14 19:17pm    
The SQL cast? Why? Are you storing time data in string data type, such as varchar? Why?! You need to store time using time data types, such as DATE...
—SA
beljk 14-Sep-14 19:26pm    
No ,, data type of field is DATETIME2 ... i changed the query like this and also didn't work
SELECT * FROM Parking WHERE Park_Time between '15-09-2014 01:27:09 AM' AND '15-09-2014 02:28:09 AM'
[no name] 14-Sep-14 20:23pm    
And you will get that if the database does not recognize the string as a valid datetime according to the database settings.

1 solution

SELECT * FROM Parking WHERE Park_Time between cast( '09/15/2014 01:27:09' AS DATETIME2) AND cast('09/15/2014 02:28:09' AS DATETIME2)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900