Thursday, February 16, 2012

> Date

Hello, everybody,
Can somebody tell me how I can query a field that has a date >1/1/2000?
I don't want to be specific using a BETWEEN clause.
Thanks,
AntonioI used this:
WHERE (dbo.ContrInfo.Reqd BETWEEN CONVERT(DATETIME, '2000-01-01
00:00:00', 102) AND GETDATE())
Thanks
"Antonio" wrote:

> Hello, everybody,
> Can somebody tell me how I can query a field that has a date >1/1/2000?
> I don't want to be specific using a BETWEEN clause.
> Thanks,
>
> Antonio|||Select * from mytable where date = '1/1/2000'
"Antonio" wrote:

> Hello, everybody,
> Can somebody tell me how I can query a field that has a date >1/1/2000?
> I don't want to be specific using a BETWEEN clause.
> Thanks,
>
> Antonio|||Antonio wrote:

> Hello, everybody,
> Can somebody tell me how I can query a field that has a date
> I don't want to be specific using a BETWEEN clause.
> Thanks,
>
> Antonio
Like this:
Select * from Table where DateColumn > '2000-01-01'
HTH,
Stijn Verrept.|||Because of the Time portion of a DateTime column, you need to specify a
duration.
And... always use a date format that won't confuse the database.
declare @.dateSearched datetime
set @.dateSearched = '20000101'
...where yourColumn >= @.dateSearched and yourColumn < dateadd(d, 1,
@.dateSearched)
If you insist on converting the column: CONVERT(DATETIME, '2000-01-01
00:00:00', 102) AND GETDATE())
check the query plan of both your solution and mine.
SQL may not be able to use indexes on that column if you use Convert.
What I gave you is the "standard" way of doing this.
"Antonio" <Antonio@.discussions.microsoft.com> wrote in message
news:F637849A-A907-4EA8-8C56-C30C3625642E@.microsoft.com...
> Hello, everybody,
> Can somebody tell me how I can query a field that has a date >1/1/2000?
> I don't want to be specific using a BETWEEN clause.
> Thanks,
>
> Antonio

No comments:

Post a Comment