Wednesday, February 08, 2012

SqlServer–getting only the date part of DateTime field

One method is to use the DatePart method.

But here is a much nicer way to get the Date Portion:

CAST(FLOOR( CAST( GETDATE() AS FLOAT ) )AS DATETIME)

No comments:

Post a Comment

Remember, if you want me to respond to your comment, then you need to use a Google/OpenID account to leave the comment.