Wednesday, March 21, 2012

Datetime Selection II

I posted this earlier and got an unusable answer, so I'm trying again...
I have a table with a transaction date of datatype datetime. I need to
select all where where the transaction date is 2 days ago. If I use
"where transaction date = (getdate( ) -2)" the selection fails because of, I
think, the time portion of each field. How can I compare two datetime
datatypes based only on the date portion?
Thank you!
Stan Gosselin
On Mon, 6 Feb 2006 14:46:25 -0800, Stan wrote:

>I posted this earlier and got an unusable answer, so I'm trying again...
>I have a table with a transaction date of datatype datetime. I need to
>select all where where the transaction date is 2 days ago. If I use
>"where transaction date = (getdate( ) -2)" the selection fails because of, I
>think, the time portion of each field. How can I compare two datetime
>datatypes based only on the date portion?
>Thank you!
Hi Stan,
I posted a reply to your original post, half an hour after you sent this
copy of the message (but before I saw it).
Was it useful?
Hugo Kornelis, SQL Server MVP

No comments:

Post a Comment