I am using a Text box to gather a Date from a User. I use this information to parse a sql statement for more data. Unfortunately when a user enters a date like
5/5/08
I get a
Syntax error converting datetime from character string.
but when i enter
5/5/2008 it works?
is there anyway when the user clicks off the text box a validation can correct the year to 4 digits to please SQL Server?
Here is my SQL Statement with the syntax error
To correct the syntax error the date just needs to be 2008? since looking into data validation, all I can come up with is a date compare? I do not see how this will help me in my situation?
Thanks
5/5/08
I get a
Syntax error converting datetime from character string.
but when i enter
5/5/2008 it works?
is there anyway when the user clicks off the text box a validation can correct the year to 4 digits to please SQL Server?
Here is my SQL Statement with the syntax error
Code:
SELECT TOP 1 Val FROM FTBL_GritChamber WHERE (TagIndex = '40' OR TagIndex = '39') AND (DateAndTime BETWEEN CONVERT(DATETIME, '5/5/08 2:03:00 PM', 102) AND CONVERT(DATETIME, '5/5/08 2:23:00 PM', 102))
Thanks