Hadason
3/19/2007 5:24:00 PM
On Mar 19, 3:56 pm, Roy Harvey <roy_har...@snet.net> wrote:
> On 19 Mar 2007 06:21:53 -0700, "Hadas" <Hada...@gmail.com> wrote:
>
> >I am looking for a way to set a new DATETIME variable using system
> >functions like DATEADD but I must initialize the variable to some
> >DATETIME before I can use DATEADD.
>
> For that I suggest using date "zero":
>
> SELECT convert(datetime,0)
> 1900-01-01 00:00:00.000
>
> Anyone familiar with SQL Server will recognize this date. It is also
> a common ingredient in truncating the time portion of a datetime:
>
> SELECT dateadd(day,datediff(day,0,getdate()),0)
> 2007-03-19 00:00:00.000
>
> Roy Harvey
> Beacon Falls, CT
That is a great way to truncate the time portion. thanks for the
suggestion.