Re: Selecting record with specific datetime
From: Aaron [SQL Server MVP] (ten.xoc_at_dnartreb.noraa)
Date: 03/01/05
- Next message: Alejandro Mesa: "RE: Selecting record with specific datetime"
- Previous message: Simon Worth: "Re: SQL Query Help: catching a missing number"
- In reply to: Keetra44: "Selecting record with specific datetime"
- Next in thread: Keetra44: "Re: Selecting record with specific datetime"
- Reply: Keetra44: "Re: Selecting record with specific datetime"
- Reply: Keetra44: "Re: Selecting record with specific datetime"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 1 Mar 2005 16:11:25 -0500
How about using a standard format and forgetting all that CAST stuff (why
would float ever come into this?)...
SELECT <columns> FROM TABLENAME
WHERE DATETIMECOLUMN = '2004-05-21T11:10:10'
-- http://www.aspfaq.com/ (Reverse address to reply.) "Keetra44" <Keetra44@discussions.microsoft.com> wrote in message news:7A2DA9E5-B1AB-4FFA-8DCD-DB70DFBBD742@microsoft.com... > I have a table with a field of type datetime whose default value is > getdate(). So, when a user entered a new record at > '5/21/2004 11:10:10 AM', that value was automatically entered in that > column. > > Now I'm trying to write a select query that will retrieve that particular > record based on that value (the rest of the fields in the record aren't > necessarily unique). > I've been fooling around with Cast and Convert and just can't seem to get it > right. Here's where I'm at so far: > > Select * from TABLENAME where DATETIMEFIELD = > CAST(CAST('5/21/2004 11:10:10 AM' AS datetime) AS float) > > Unfortunately, the query returns zero results. How do I need to modify this > query to return the result that I know exists in the table? > > Thanks in advance.
- Next message: Alejandro Mesa: "RE: Selecting record with specific datetime"
- Previous message: Simon Worth: "Re: SQL Query Help: catching a missing number"
- In reply to: Keetra44: "Selecting record with specific datetime"
- Next in thread: Keetra44: "Re: Selecting record with specific datetime"
- Reply: Keetra44: "Re: Selecting record with specific datetime"
- Reply: Keetra44: "Re: Selecting record with specific datetime"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|