Re: Help with Current DATE in Query



SQL Brad,

There are several ways to get the date only, without time included. This is
one of the best performing since it uses math instead of character string
conversions:

DATEADD(DD,DATEDIFF(DD,'1/1/1753',GetDate()),'1/1/1753') -- Any origin
date will do

Assuming that your DATE columns only have date set (and time set to
00:00:00.000) then this will work for you. If your transactions have date
and time, then:

WHERE DATEADD(DD,DATEDIFF(DD,'1/1/1753',MyDateColumn,'1/1/1753')
= DATEADD(DD,DATEDIFF(DD,'1/1/1753',GetDate()),'1/1/1753')

RLF

"SQL Brad" <SQLBrad@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:438183F5-03BA-47DF-8185-708EDB71AE4D@xxxxxxxxxxxxxxxx
Hello, I have a table that lists my bank transactions. I have a uniqueid
in
the first field and several other fields....one of which is DATE.... now,
I
want to run a query where my view is based upon the DATE. however I want
to
only show transactions that are the same date as the system date (this is
to
see how much work my employees have done). Please see my example below,
this
code works....

SELECT transid, [date], description, amt, taxamt
FROM dbo.taxtransactions
WHERE ([date] = '9/9/2007')

However, where it has 9/9/2007, I want it to be TODAYS Date

Thanks for your help in advance!


.