Re: Date Selection
- From: Hugo Kornelis <hugo@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 07 Feb 2006 00:16:38 +0100
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
.
- Prev by Date: Re: Changing Ordering
- Next by Date: Re: Datetime Selection II
- Previous by thread: Re: Selecting data from one table based on conditions in another table
- Next by thread: Re: Datetime Selection II
- Index(es):