Re: Selecting record with specific datetime

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Aaron [SQL Server MVP] (ten.xoc_at_dnartreb.noraa)
Date: 03/01/05


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.


Relevant Pages

  • Re: Selecting record with specific datetime
    ... I'm not sure why float comes into it. ... > How about using a standard format and forgetting all that CAST stuff (why ... >> I've been fooling around with Cast and Convert and just can't seem to get ... the query returns zero results. ...
    (microsoft.public.sqlserver.programming)
  • Re: Selecting record with specific datetime
    ... I'm not really sure why float would ever come into this. ... changing the date format to your standard format didn't help ... me receive any results in my query. ... >> I've been fooling around with Cast and Convert and just can't seem to get ...
    (microsoft.public.sqlserver.programming)
  • Re: internals of typecasting
    ... > object of type int is applied an cast of float the result ... > would be of type float. ... casting from floating-point numbers to integers. ...
    (comp.lang.c)
  • Re: 12.34f vs (float) 12.34
    ... where cast followed by a literal parses the literal ... believe the compiler makes passes over the statement/expression trees it has ... generated, looking for certain patterns, and replacing them with ... float it's not guaranteed to be no more than a float. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: libc/printf bug
    ... I don't see that the cast should have any effect at all ... How would you print a float in hex? ... So if you wite %x the thing will increment stackpointer by some bytes to ...
    (comp.os.linux.development.apps)