|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Date part of GETDATE()?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. Rick Charnes wrote:
> Is there an easy way to get today's date without the time part? Or I http://realsqlguy.com/serendipity/archives/5-No-Time-For-DATETIME-Values.html> 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. 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. 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. |
|||||||||||||||||||||||