You can't really "...get a Date part out of GetDate() ..." (or any other datetime type for that matter) because by definition the datatype contains both a date
and a time.
You can however choose to ignore the time portion by setting it to midnight - if all the datetimes you deal with have their time portion set to the same value you are in effect ignoring the time. This can be accomplished by exploiting the fact that SQL Server will by default set the time portion to midnight when converting a string representation of a date which does not include a time to a datetime type.
Thus the expression:
Code:
CONVERT(char(8),<yourdatetime>,112)
will convert <yourdatetime> to a string in the format yyyymmdd, discarding any time portion of the data. If you then convert that string back to a datetime, the time portion will be set to midnight, thus in effect discarding the time. So, for your question using GetDate():
Code:
CAST(CONVERT(char(8),GetDate(),112) as datetime)
results in a datetime type of today's date without the time.
This BS will eventually go away, as the next release of SQL Server ('Yukon') will finally support the DATE and TIME datatypes which behave as you'd expect.
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com