Home All Groups Group Topic Archive Search About

Date part of GETDATE()?

Author
24 Aug 2006 3:59 PM
Rick Charnes
Is there an easy way to get today's date without the time part?  Or I
guess I should say I need to assign a variable that contains today's
date, with 00:00:00:00 as the time part.  Thanks.

Author
24 Aug 2006 4:04 PM
Tracy McKibben
Rick Charnes wrote:
> Is there an easy way to get today's date without the time part?  Or I
> guess I should say I need to assign a variable that contains today's
> date, with 00:00:00:00 as the time part.  Thanks.

http://realsqlguy.com/serendipity/archives/5-No-Time-For-DATETIME-Values.html


--
Tracy McKibben
MCDBA
http://www.realsqlguy.com
Author
24 Aug 2006 4:05 PM
Roy Harvey
select dateadd(day,datediff(day,0, getdate()),0)

Roy Harvey
Beacon Falls, CT

On Thu, 24 Aug 2006 11:59:27 -0400, Rick Charnes
<rickxyz--nospam.zyxcharnes@thehartford.com> wrote:

Show quote
>Is there an easy way to get today's date without the time part?  Or I
>guess I should say I need to assign a variable that contains today's
>date, with 00:00:00:00 as the time part.  Thanks.
Author
24 Aug 2006 4:14 PM
Aaron Bertrand [SQL Server MVP]
A couple of ways:

DECLARE @dt SMALLDATETIME;

-- my preference and most efficient I believe:
SET @dt = DATEDIFF(DAY, 0, CURRENT_TIMESTAMP);
SELECT @dt;

-- ODBC:
SET @dt = {fn CurDate()};
SELECT @dt;

-- brute force / multiple conversions (least efficient):
SET @dt = CONVERT(CHAR(10), CURRENT_TIMESTAMP, 112);
SELECT @dt;



Show quote
"Rick Charnes" <rickxyz--nospam.zyxcharnes@thehartford.com> wrote in message
news:MPG.1f5796e8893ba9fe98994a@msnews.microsoft.com...
> Is there an easy way to get today's date without the time part?  Or I
> guess I should say I need to assign a variable that contains today's
> date, with 00:00:00:00 as the time part.  Thanks.

AddThis Social Bookmark Button