Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL With Date
Message
General information
Forum:
ASP.NET
Category:
Databases
Title:
Miscellaneous
Thread ID:
00792639
Message ID:
00793203
Views:
65
Thanks Michael.

>In all honest, you'd be better off formating your dates as YYYYMMDD instead of submitting SET DATEFORMAT with each command.
>
>-Mike
>
>>Thank you Mike for your reply.
>>
>>Can I set/change the "SET DATEFORMAT" in my .Net project, to garanty the dateformat will not be changed.
>>
>>And if yes, where I can keep these changes, is it an sql command I pass it to the server?
>>
>>BR
>>
>>
>>>SQL Server interprets date literals according to the SET DATEFORMAT setting which is set on the connection. If possible, supply your dates in the form of YYYYMMDD. SQL Server will also read this format correctly, regardless of the setting of SET DATEFORMAT.
>>>
>>>-Mike
>>>
>>>>Hi Bonnie,
>>>>
>>>>Yes, I am geeting an error:
>>>>"The conversion of a char data type to a datetime data type resulted in an out of range datetime value."
>>>>
>>>>also I am getting this error in the "Quary Analyzer" as Cathi told me to test it there, same error esactly.
>>>>
>>>>But, I did some test ...
>>>>I replaced the sql part of
DateIn = '" & Date.Today.ToString() & "'"
>>>>with
>>>>
>>>>Dim myAttendanceSql As String = "SELECT * FROM AN_CheckInOut WHERE Mem_EmpID = '" & Trim(Me.txtID.Text) & "' AND DateIn = '05/25/2003'"
>>>>
>>>>this way it accept it, that means the problem with the date format, if I used 'MM/DD/YYYY' format in the query it works fine but if I used 'DD/MM/YYYY' which is out country standard it does not work.
>>>>
>>>>This means also I have to change all my SQL statments which deals with the date to 'MM/DD/YYYY' format !!!!
>>>>
>>>>To bad, I told you guys befor I hate Microsoft :)
>>>>
>>>>Many thanks for all of you.
>>>>
>>>>
>>>>
>>>>>Ahmad,
>>>>>
>>>>>Are you sure you get an error with this? SQL recognizes date "strings" as Dates. What error are you getting?
>>>>>
>>>>>~~Bonnie
>>>>>
>>>>>
>>>>>>Hi Cathi,
>>>>>>
>>>>>>I can't include .ToString() in the quary, because the "DateIn" field is a date type.
>>>>>>I get a conversion error if I add it.
>>>>>>
>>>>>>
>>>>>>>Hi Ahmad,
>>>>>>>
>>>>>>>Try changing the select statement to the following:
>>>>>>>
>>>>>>>
>>>>>>>Dim myAttendanceSql As String = "SELECT * FROM AN_CheckInOut WHERE Mem_EmpID = '" & Trim(Me.txtID.Text) & "' AND DateIn = '" & Date.Today.ToString() & "'"
>>>>>>>
>>>>>>>
>>>>>>>Also keep in mind that SQL Server uses DateTime and not just Date. Therefore your DateIn expression must match both the date portion and the time portion exactly.
>>>>>>>
>>>>>>>>Dear All,
>>>>>>>>
>>>>>>>>Am I missing somthing with this SQL statment:
>>>>>>>>
>>>>>>>>Dim myAttendanceSql As String = "SELECT * FROM AN_CheckInOut WHERE Mem_EmpID = '" & Trim(Me.txtID.Text) & "' AND DateIn = " & Date.Today
>>>>>>>>Dim myAttendanceDA As New SqlDataAdapter(myAttendanceSql, myConn.oAdoNetSql_Conn)
>>>>>>>>Dim myAttendanceCB As New SqlCommandBuilder(myAttendanceDA)
>>>>>>>>
>>>>>>>>
>>>>>>>>It return 0 rows if I included the date in the query. and no errors!
>>>>>>>>
>>>>>>>>I am using SQL2000 MSDE.
>>>>>>>>
>>>>>>>>Thanks for the help.
<><><><><><><><><><><><><><><><><><><><>
<><> REMEMBER,,,,KNOWLEDGE IS POWER <><>
<><><><><><><><><><><><><><><><><><><><>
Previous
Reply
Map
View

Click here to load this message in the networking platform