"Mystery Man" <Pr************@hotmail.com> wrote in message
news:87**************************@posting.google.c om...
Does anyone know if Microsoft is planning to add a DATE only data type
to SQLServer.
I know that you could use a datetime and convert/cast or use datepart
to compare, but this can be tedious and error prone.
What is the recommended way to compare date-only fields?
eg if convert(char(11), @date_field) = convert(getdate(), @date_field)
-- do something??
There's an article in the November 2003 edition of SQL Server Magazine about
TSQL enhancements in Yukon, according to which the answer is yes.
http://www.sqlmag.com/Articles/Index...rticleID=40206
As for comparing dates only, you have to use one of the options you noted
above - DATEPART() or CONVERT():
if convert(char(8), col1, 112) = convert(char(8), col2, 112)
begin
...
end
If your application only uses dates, not times, you may be able to assume
that all times are 00:00.000, in which case you can always compare datetime
values directly. But this is a potentially risky assumption, unless you're
sure that all data entry enforces this rule.
Simon