[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.sqlserver.programming

DATETIME Min value constant

Hadason

3/19/2007 1:22:00 PM

Hello,

I was wondering if there is any constant that defines the min range of
a DATETIME type in SQL server.
I know it's: 1753-01-01 00:00:00.000 or -53690.00000 but I prefer
using a defined system constant (if any).

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.

Any suggestions?

thanks.

2 Answers

Roy Harvey

3/19/2007 1:57:00 PM

0

On 19 Mar 2007 06:21:53 -0700, "Hadas" <Hadason@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

Hadason

3/19/2007 5:24:00 PM

0

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.