Re: Date Selection



On Mon, 6 Feb 2006 06:52:43 -0800, Stan wrote:

I thought this was simple but...
I have a table with a transdate of data type datetime and I want to select
all transactions either for today or for getdate() minus some value. Looks
to me like the time portion is getting in the way of "where transdate =
(getdate() - 3)". How do I deal with just the date portions of these fields?
Thanks

Hi Stan,

To remove the time portion from a datetime column (or variable), use

SELECT DATEADD(day, DATEDIFF(day, 0, CURRENT_TIMESTAMP), 0)


--
Hugo Kornelis, SQL Server MVP
.