|
-
Mar 13th, 2004, 07:19 AM
#1
Thread Starter
Lively Member
SQL query by Datetime
I have a table in my SQL Server DB that contains a DateTime type field set up as the Primary Key. I have the following code that performs a search:
Code:
string SQL = "SELECT * FROM [MyEventLog] Where [theDate] = '13/03/2004 08:22:37';
SqlCommand sqlComm = new SqlCommand(SQL,sqlConn);
SqlDataReader sqlReader = sqlComm.ExecuteReader();
while(sqlReader.Read())
{
richNote.Text = sqlReader["theNote"].ToString();
}
There is definately a record that contains the date and time mentioned above, but my sql cannot find it. Do i need to convert something or change the sql query structure?
anyone?
thanks
-
Mar 13th, 2004, 10:11 AM
#2
PowerPoster
I don't see a AM or PM in the date time.
Check your SQL table again and see if the value contains that part....I think it does.
-
Mar 13th, 2004, 10:29 AM
#3
Hyperactive Member
If you haven't made any changes to how sql server stores datetime fields, it'll be stored like this:
Code:
2004-03-13 09:05:48.157
...note the trailing .157. There might be some change on the end of it.
-
Mar 17th, 2004, 12:12 AM
#4
Hyperactive Member
Just curious. Why would you use a date as a primary key?
..::[ kleptos]::..
- Database Administrator (MSSQL 2000)
- Application Developer (C#)
- Web Developer (ASP.NET)

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|